2022-08-26 19:19:11 +00:00
|
|
|
##
|
|
|
|
# Performs follow-up tasks when a workflow fails or is cancelled.
|
|
|
|
##
|
|
|
|
name: Failed Workflow
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
run_id:
|
|
|
|
description: 'ID of the GitHub Action workflow run to rerun'
|
|
|
|
required: true
|
|
|
|
type: 'string'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
# Attempts to rerun a workflow.
|
|
|
|
#
|
|
|
|
# Performs the following steps:
|
|
|
|
# - Retrieves the workflow run that dispatched this workflow.
|
|
|
|
# - Restarts all failed jobs when the workflow fails or is cancelled for the first time.
|
|
|
|
failed-workflow:
|
|
|
|
name: Rerun a workflow
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 5
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Rerun a workflow
|
2023-01-27 19:23:20 +00:00
|
|
|
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
|
2022-08-26 19:19:11 +00:00
|
|
|
with:
|
2022-09-28 01:53:48 +00:00
|
|
|
retries: 2
|
|
|
|
retry-exempt-status-codes: 418
|
2022-08-26 19:19:11 +00:00
|
|
|
script: |
|
|
|
|
const workflow_run = await github.rest.actions.getWorkflowRun({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
run_id: ${{ inputs.run_id }},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Only rerun after the first run attempt.
|
|
|
|
if ( workflow_run.data.run_attempt > 1 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const rerun = await github.rest.actions.reRunWorkflowFailedJobs({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
run_id: ${{ inputs.run_id }},
|
2022-09-20 16:54:29 +00:00
|
|
|
enable_debug_logging: true
|
2022-08-26 19:19:11 +00:00
|
|
|
});
|