diff --git a/.github/workflows/release-to-prod.yml b/.github/workflows/release-to-prod.yml index ee44ca23312..96a799efa8b 100644 --- a/.github/workflows/release-to-prod.yml +++ b/.github/workflows/release-to-prod.yml @@ -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"' diff --git a/.github/workflows/release-to-staging.yml b/.github/workflows/release-to-staging.yml index a420d54ec72..139b8472fa8 100644 --- a/.github/workflows/release-to-staging.yml +++ b/.github/workflows/release-to-staging.yml @@ -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: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd303713775..a4cc2323d8c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,7 @@ on: push: branches-ignore: - "release-please--**" + - "release/v**" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true