Skip to content

Commit

Permalink
fix: support edge cases in release to prod (#9364)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <matt.krick@gmail.com>
  • Loading branch information
mattkrick committed Jan 18, 2024
1 parent 982e494 commit 006d714
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/release-to-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,28 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Push to Production Server
- name: Get Job ID from PR
run: |
JOB_ID=$(echo ${{ github.event.pull_request.body}} | perl -ne 'print "$1\n" and exit if m/^Production Job Id:\s(\w+)/;')
echo "JOB_ID=${JOB_ID}" >> $GITHUB_ENV
curl "https://gitlab.com/api/v4/projects/${{ vars.GITLAB_PROJECT_ID }}/jobs/$JOB_ID/play" \
--request POST \
--header 'PRIVATE-TOKEN: ${{ secrets.GITLAB_API_TOKEN }}'
- name: Push to Production Server
uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 100
retry_wait_seconds: 5
# If the job isn't created yet, will return {"message":"400 Bad request - Unplayable Job"}
command: |
RES=$(curl "https://gitlab.com/api/v4/projects/${{ vars.GITLAB_PROJECT_ID }}/jobs/${{ env.JOB_ID }}/play" \
--request POST \
--header 'PRIVATE-TOKEN: ${{ secrets.GITLAB_API_TOKEN }}')
echo $RES
JOB_ID_DONE=$(echo $RES | jq '.id // empty')
[ -z "$JOB_ID_DONE" ] && exit 1 || exit 0
- name: Poll Production Release
uses: artiz/poll-endpoint@1.0.2
with:
url: https://gitlab.com/api/v4/projects/${{ vars.GITLAB_PROJECT_ID }}/jobs/${{ env.JOB_ID }}
url: https://gitlab.com/api/v4/projects/${{ vars.GITLAB_PROJECT_ID }}/jobs/${{ env.JOB_ID }}?access_token=${{ secrets.GITLAB_API_TOKEN }}
method: GET
expect-status: 200
expect-response-regex: '"status":"success"'
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release-to-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ jobs:
--header 'PRIVATE-TOKEN: ${{ secrets.GITLAB_API_TOKEN }}')
echo $RES
JOB_ID_DONE=$(echo $RES | jq '.id // empty')
echo $JOB_ID_DONE
[ -z "$JOB_ID_DONE" ] && echo nully || echo "not null"
[ -z "$JOB_ID_DONE" ] && exit 1 || exit 0
- name: Open PR to Push to Prod
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches-ignore:
- "release-please--**"
- "release/v**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down

0 comments on commit 006d714

Please sign in to comment.