|
29 | 29 | permissions: write-all
|
30 | 30 |
|
31 | 31 | env:
|
| 32 | + GH_CLI_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + GH_CLI_TOKEN_PR: ${{ secrets.SELENIUM_CI_TOKEN || secrets.GITHUB_TOKEN }} |
| 34 | + RUN_ID: ${{ github.run_id }} |
| 35 | + RERUN_FAILED_ONLY: ${{ github.event.inputs.rerunFailedOnly || true }} |
| 36 | + RUN_ATTEMPT: ${{ github.run_attempt }} |
32 | 37 | FORCE_RELEASE: ${{ github.event.inputs.release == 'true' }}
|
33 | 38 |
|
34 | 39 | jobs:
|
@@ -124,3 +129,32 @@ jobs:
|
124 | 129 | with:
|
125 | 130 | github_token: ${{ secrets.SELENIUM_CI_TOKEN || secrets.GITHUB_TOKEN }}
|
126 | 131 | branch: trunk
|
| 132 | + |
| 133 | + rerun-workflow-when-failure: |
| 134 | + name: Rerun workflow when failure |
| 135 | + needs: |
| 136 | + - helm-chart-test |
| 137 | + if: failure() && ( github.run_attempt < 3 ) |
| 138 | + runs-on: ubuntu-24.04 |
| 139 | + steps: |
| 140 | + - name: Checkout code |
| 141 | + uses: actions/checkout@main |
| 142 | + - name: Install GitHub CLI |
| 143 | + run: | |
| 144 | + sudo apt update |
| 145 | + sudo apt install gh |
| 146 | + - name: Authenticate GitHub CLI for PR |
| 147 | + if: github.event_name == 'pull_request' |
| 148 | + run: | |
| 149 | + echo "$GH_CLI_TOKEN_PR" | gh auth login --with-token |
| 150 | + - name: Authenticate GitHub CLI |
| 151 | + if: github.event_name != 'pull_request' |
| 152 | + run: | |
| 153 | + echo "$GH_CLI_TOKEN" | gh auth login --with-token |
| 154 | + - name: Rerun workflow when failure |
| 155 | + run: | |
| 156 | + echo "Rerun workflow ID $RUN_ID in attempt #$(($RUN_ATTEMPT + 1))" |
| 157 | + gh workflow run rerun-failed.yml \ |
| 158 | + --repo $GITHUB_REPOSITORY \ |
| 159 | + --raw-field runId=$RUN_ID \ |
| 160 | + --raw-field rerunFailedOnly=$RERUN_FAILED_ONLY |
0 commit comments