@@ -2,10 +2,25 @@ name: Update Dev/Beta Browser Images
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ rerunFailedOnly :
7+ description : ' Rerun only failed jobs'
8+ required : false
9+ type : boolean
10+ default : true
511 schedule :
612 # Trigger build every 2 days
713 - cron : ' 0 2 */2 * *'
814
15+ permissions : write-all
16+
17+ env :
18+ GH_CLI_TOKEN : ${{ secrets.GITHUB_TOKEN }}
19+ GH_CLI_TOKEN_PR : ${{ secrets.SELENIUM_CI_TOKEN || secrets.GITHUB_TOKEN }}
20+ RUN_ID : ${{ github.run_id }}
21+ RERUN_FAILED_ONLY : ${{ github.event.inputs.rerunFailedOnly || true }}
22+ RUN_ATTEMPT : ${{ github.run_attempt }}
23+
924jobs :
1025
1126 deploy :
@@ -94,3 +109,33 @@ jobs:
94109 docker run --rm $NAME/standalone-$BROWSER:$CHANNEL bash -c "$BROWSER_VERSION_COMMAND"
95110 echo "$BROWSER_CAPS $CHANNEL_CAPS WebDriver version:"
96111 docker run --rm $NAME/standalone-$BROWSER:$CHANNEL bash -c "$DRIVER_VERSION_COMMAND"
112+
113+
114+ rerun-workflow-when-failure :
115+ name : Rerun workflow when failure
116+ needs :
117+ - deploy
118+ if : failure() && ( github.run_attempt < 3 )
119+ runs-on : ubuntu-latest
120+ steps :
121+ - name : Checkout code
122+ uses : actions/checkout@main
123+ - name : Install GitHub CLI
124+ run : |
125+ sudo apt update
126+ sudo apt install gh
127+ - name : Authenticate GitHub CLI for PR
128+ if : github.event_name == 'pull_request'
129+ run : |
130+ echo "$GH_CLI_TOKEN_PR" | gh auth login --with-token
131+ - name : Authenticate GitHub CLI
132+ if : github.event_name != 'pull_request'
133+ run : |
134+ echo "$GH_CLI_TOKEN" | gh auth login --with-token
135+ - name : Rerun workflow when failure
136+ run : |
137+ echo "Rerun workflow ID $RUN_ID in attempt #$(($RUN_ATTEMPT + 1))"
138+ gh workflow run rerun-failed.yml \
139+ --repo $GITHUB_REPOSITORY \
140+ --raw-field runId=$RUN_ID \
141+ --raw-field rerunFailedOnly=$RERUN_FAILED_ONLY
0 commit comments