diff --git a/.github/workflows/failure-handler.yml b/.github/workflows/failure-handler.yml index 167439a397..c91d7fafd0 100644 --- a/.github/workflows/failure-handler.yml +++ b/.github/workflows/failure-handler.yml @@ -11,7 +11,7 @@ on: required: true type: string team_id: - description: 'ID of Jira Team' + description: 'ID of Jira Team.' required: true type: string secrets: # all secrets are passed explicitly in this workflow @@ -23,8 +23,27 @@ permissions: issues: write jobs: + retry-on-failure: + # do not trigger more than 3 times + if: fromJSON(github.run_attempt) < 3 + runs-on: ubuntu-latest + steps: + - name: rerun ${{ github.run_id }} + env: + GH_REPO: mongodb/openapi + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # We cannot trigger the retry directly because the action is still running. + # We wait for the action to complete and then trigger the retry for the failed steps. + gh run watch ${{ github.run_id }} > /dev/null 2>&1 + gh run rerun ${{ github.run_id }} --failed + failure-handler: runs-on: ubuntu-latest + needs: retry-on-failure + # If the result of retry-on-failure is 'skipped', it means the workflow has already been retried 3 times. + # In this case, create a Jira ticket and a GitHub issue. + if: always() && needs.retry-on-failure.result == 'skipped' steps: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -33,9 +52,9 @@ jobs: .github/ISSUE_TEMPLATE/GH_ACTION_ISSUE_TEMPLATE.md .github/scripts/create_jira_ticket.sh - - name: Check if an issue already exists + - name: Check if an issue already exists id: check-issue - env: + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TARGET_ENV: ${{ inputs.env }} RELEASE_NAME: ${{ inputs.release_name }}