-
Notifications
You must be signed in to change notification settings - Fork 1
33 lines (25 loc) · 1.06 KB
/
retry-job.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
name: Hello World Action
on:
pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Print Hello World
run: echo "Hello, World!"
- name: Print Hello World
if: ${{ cancelled() }}
run: |
# Get the run ID of the workflow that just completed
RUN_ID=$(echo $GITHUB_EVENT_PATH | jq -r .workflow_run.id)
# Fetch information about the workflow run
API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${RUN_ID}"
WORKFLOW_RUN=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $API_URL)
# Extract information needed for rerun
REPO_OWNER=$(echo $WORKFLOW_RUN | jq -r .repository.owner.login)
REPO_NAME=$(echo $WORKFLOW_RUN | jq -r .repository.name)
# Rerun failed jobs
RERUN_URL="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/runs/${RUN_ID}/rerun-failed-jobs"
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $RERUN_URL