# A hosted runner of a private repository may land on a host with no KVM, which fails the "Enable # KVM" step of .github/actions/nix. Another attempt usually gets another host, so a run that failed # only for that is rerun, up to three attempts. A suite that fails is left alone. A run cannot rerun # its own failed jobs while it is still in progress, hence a workflow of its own. name: rerun-no-kvm on: workflow_run: workflows: [ci] types: [completed] jobs: rerun: if: >- github.repository == 'LGUG2Z/komorebi-for-kde' && github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt < 3 runs-on: ubuntu-24.04 permissions: actions: write steps: - name: Rerun the failed jobs when every one of them failed to get KVM env: GH_TOKEN: ${{ github.token }} RUN_ID: ${{ github.event.workflow_run.id }} REPO: ${{ github.repository }} run: | # for each failed job, the name of the step that failed failed=$(gh api --paginate "repos/$REPO/actions/runs/$RUN_ID/jobs?filter=latest" \ --jq '.jobs[] | select(.conclusion == "failure") | [.name, ([.steps[] | select(.conclusion == "failure") | .name] | first // "")] | @tsv') echo "$failed" if [ -z "$failed" ] || printf '%s\n' "$failed" | awk -F'\t' '$2 !~ /Enable KVM/ { bad = 1 } END { exit !bad }'; then echo "something other than a missing /dev/kvm failed: not rerunning" exit 0 fi gh run rerun "$RUN_ID" --repo "$REPO" --failed