Skip to content

Commit

Permalink
ci: auto deploys working
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieC3 committed Jun 15, 2021
1 parent bf77bf9 commit 6ca3046
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,15 @@ jobs:

auto-approve-staging:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
# if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v')
needs:
- build-publish
steps:
- name: Approve pending deployment
run: |
ENV_ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/blockstack/explorer/actions/runs/${{ github.run_id }}/pending_deployments" | jq -r '.[0].environment.id // empty')
if [[ -n "${ENV_ID}" ]]; then
echo "ENV_ID is ${ENV_ID}"
set -x
curl -s -X POST -H "Authorization: token ${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/blockstack/explorer/actions/runs/${{ github.run_id }}/pending_deployments" -d "{\"environment_ids\":[${ENV_ID}],\"state\":\"approved\",\"comment\":\"auto approve\"}"
set +x
fi
deploy-prod:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ jobs:
gh_token: ${{ secrets.GH_TOKEN }}
docker_tag: ${{ github.event.inputs.tag }}

auto-approve-staging:
runs-on: ubuntu-latest
needs:
- build-publish
steps:
- name: Approve pending deployment
run: |
ENV_ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/blockstack/explorer/actions/runs/${{ github.run_id }}/pending_deployments" | jq -r '.[0].environment.id // empty')
if [[ -n "${ENV_ID}" ]]; then
curl -s -X POST -H "Authorization: token ${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/blockstack/explorer/actions/runs/${{ github.run_id }}/pending_deployments" -d "{\"environment_ids\":[${ENV_ID}],\"state\":\"approved\",\"comment\":\"auto approve\"}"
fi
deploy-prod:
runs-on: ubuntu-latest
needs:
Expand Down

0 comments on commit 6ca3046

Please sign in to comment.