Support running e2e tests across different Gw API versions #270
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Re-run failed jobs | |
| on: | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| retest: | |
| # only run this job on PR comments from org members/owners where the comment is exactly "/retest" | |
| if: | | |
| github.event.issue.pull_request && | |
| (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && | |
| github.event.comment.body == '/retest' | |
| permissions: | |
| contents: read | |
| actions: write | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Re-run failed jobs | |
| shell: bash | |
| env: | |
| PR_NUMBER: ${{ github.event.issue.number }} | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # get the SHA of the PR's latest commit | |
| commit_sha=$(gh pr view "$PR_NUMBER" --json headRefOid --jq '.headRefOid') | |
| if [[ -z "$commit_sha" ]]; then | |
| echo "cannot get latest commit sha for pr number=$PR_NUMBER; gh --version:" | |
| gh --version | |
| exit 1 | |
| fi | |
| echo "pr number=$PR_NUMBER, latest commit sha=$commit_sha" | |
| # get the failing workflow run IDs (if any) associated with the latest commit | |
| failing_run_ids=$(gh run list --commit "$commit_sha" --status failure --json databaseId | jq '.[].databaseId' -r) | |
| # if no failing workflow runs found, exit | |
| if [[ -z "$failing_run_ids" ]]; then | |
| echo "No failing workflow runs found" | |
| exit 0 | |
| fi | |
| # re-run the failing workflow runs (this enqueues each workflow run and returns immediately) | |
| for run_id in $failing_run_ids; do | |
| echo "Re-running failed workflow run $run_id" | |
| gh run rerun "$run_id" --failed | |
| done |