GitHub/rerun: Difference between revisions

From Omnia
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:
* ref: https://stackoverflow.com/questions/71574593/how-to-automatically-retry-github-action-jobs-on-failure
* ref: https://stackoverflow.com/questions/71574593/how-to-automatically-retry-github-action-jobs-on-failure
* ref: https://github.com/orgs/community/discussions/67654#discussioncomment-8038649
* ref: https://github.com/orgs/community/discussions/67654#discussioncomment-8038649
something along the lines of:
<pre>
    steps:
      - name: Rerun failed jobs in the current workflow
        env:
          GH_TOKEN: ${{ github.token }}
        run: gh run rerun ${{ github.run_id }} --failed
</pre>


=== test.yml ===
=== test.yml ===

Revision as of 09:59, 20 July 2026

auto-rerun

something along the lines of:

    steps:
      - name: Rerun failed jobs in the current workflow
        env:
          GH_TOKEN: ${{ github.token }}
        run: gh run rerun ${{ github.run_id }} --failed

test.yml

test.yml:

on: push
jobs:
  fail:
    runs-on: ubuntu-latest
    steps:
      - run: false
  re-run:
    needs: fail
    if: failure() && fromJSON(github.run_attempt) < 3
    runs-on: ubuntu-latest
    steps:
      - env:
          GH_REPO: ${{ github.repository }}
          GH_TOKEN: ${{ github.token }}
          GH_DEBUG: api
        run: gh workflow run rerun.yml -F run_id=${{ github.run_id }}

rerun.yml

on:
  workflow_dispatch:
    inputs:
      run_id:
        required: true
jobs:
  rerun:
    runs-on: ubuntu-latest
    steps:
      - name: rerun ${{ inputs.run_id }}
        env:
          GH_REPO: ${{ github.repository }}
          GH_TOKEN: ${{ github.token }}
          GH_DEBUG: api
        run: |
          gh run watch ${{ inputs.run_id }} > /dev/null 2>&1
          gh run rerun ${{ inputs.run_id }} --failed

keywords