Skip to content

rerun failed jobs

rerun failed jobs #708

Workflow file for this run

name: rerun failed jobs
on:
workflow_dispatch:
inputs:
run_id:
description: "run id"
required: true
type: string
max_attempts:
description: "max attempts, default is 3"
required: false
default: "3"
type: string
jobs:
rerun:
runs-on: ubuntu-latest
steps:
- name: re-run failed jobs
run: |
run=`curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.inputs.run_id }}`
status=`jq -r '.conclusion' <<< "$run"`
run_attempt=`jq -r '.run_attempt' <<< "$run"`
if [[ "$status" == "failure" && "$run_attempt" -lt ${{ github.event.inputs.max_attempts }} ]]; then
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.inputs.run_id }}/rerun-failed-jobs
fi