Skip to content

chore(gha): Create self-hosted runner auto-retry action #1

chore(gha): Create self-hosted runner auto-retry action

chore(gha): Create self-hosted runner auto-retry action #1

Workflow file for this run

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