Skip to content

rerun-test

rerun-test #31

Workflow file for this run

name: rerun-test
on:
workflow_dispatch:
jobs:
retry:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Check and rerun or cancel workflow
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
STATUS=$(gh run list -w test.yml | awk 'NR==4 {print $1}')
RUN_ID=$(gh run list -w test.yml | grep -oE '[0-9]{10}' | head -n 1)
if [ "$STATUS" == "completed" ]; then
echo "Job is completed, rerunning..."
gh run rerun $RUN_ID
else
echo "Job is not completed, canceling and rerunning..."
gh run cancel $RUN_ID && gh run rerun $RUN_ID
fi