# A hosted runner of a repository may land on a host with no KVM, which fails the "Enable # KVM" step of the nix action (.github/actions/nix). Another attempt usually gets another host, so a run that failed # only for that is rerun (the API lists a composite action as one step, "Run ./.github/actions/nix", not # as the steps inside it, so that is the step that is looked for in the jobs that need KVM), 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, sweeps] types: [completed] jobs: rerun: if: >- github.repository == 'LGUG2Z/komorebi' && 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' '!($1 ~ /^(vm-|canary)/ && $2 ~ /(Enable KVM|actions\/nix)/) { 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