Skip to content

Commit

Permalink
workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
userdocs committed Jan 2, 2025
1 parent a6dd3c0 commit f45b822
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 50 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci-auto-rerun-failed-jobs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: ci auto rerun failed jobs

on:
workflow_dispatch:
inputs:
run_id:
description: "The run id of the workflow to rerun"
required: true
attempts:
description: "The number of attempts to rerun the workflow"
required: true
retries:
description: "The number of retries to rerun the workflow"
required: true
github_repo:
description: "The repository to rerun the workflow"
required: false
distinct_id:
description: "The distinct id of the workflow to rerun"
required: false

run-name: ci auto rerun failed jobs - attempt ${{ inputs.attempts }}

jobs:
gh-cli-rerun:
name: rerun - attempt ${{ inputs.attempts }}
permissions:
actions: write
runs-on: ubuntu-latest
env:
GH_TOKEN: "${{ secrets.AUTO_RERUN || github.token }}"
steps:
- name: Host - Checkout action ${{ inputs.distinct_id }}
uses: actions/checkout@v4

- uses: userdocs/gh-cli-workflow-reruns/actions/auto-rerun-failed@main
with:
run_id: ${{ inputs.run_id }}
attempts: ${{ inputs.attempts }}
retries: ${{ inputs.retries }}
github_repo: ${{ inputs.github_repo || github.repository }}
distinct_id: ${{ inputs.distinct_id || github.run_id }}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ on:
retries:
description: "Number of rerun retries"
required: true
default: "1"
default: "2"
type: choice
options: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]

Expand Down Expand Up @@ -245,11 +245,23 @@ jobs:
if: >
failure() &&
( needs.scheduled_defaults.outputs.skip_rerun == 'false' && needs.skip_duplicate_job.outputs.should_skip != 'true' )
name: rerun-on-failure
concurrency:
group: ci-auto-rerun-failed-jobs
cancel-in-progress: true
permissions:
actions: write
runs-on: ubuntu-latest
env:
GH_TOKEN: "${{ secrets.AUTO_RERUN || github.token }}"
github_repo: "" # To use ci-auto-rerun-failed-jobs.yml hosted in a remote repository else default to the current repository. Requires PAT token AUTO_RERUN
steps:
- uses: actions/checkout@v4
- name: Trigger rerun workflow on job failures
run: |
inputs_retries="${{ needs.scheduled_defaults.outputs.retries }}"
gh workflow run rerun.yml -f run_id=${{ github.run_id }} -f attempts=${{ github.run_attempt }} -f retries=${inputs_retries:-1}
- name: ci-auto-rerun-failed-jobs via ${{ env.github_repo || github.repository }}
run: >
gh workflow run ci-auto-rerun-failed-jobs.yml
--repo "${{ env.github_repo || github.repository }}"
-f github_repo=${{ github.repository }}
-f run_id=${{ github.run_id }}
-f attempts=${{ github.run_attempt }}
-f retries=${{ github.event.inputs.retries || '1' }}
-f distinct_id=${{ github.event.inputs.distinct_id }}
44 changes: 0 additions & 44 deletions .github/workflows/rerun.yml

This file was deleted.

0 comments on commit f45b822

Please sign in to comment.