Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support edge cases in release to prod #9364

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading