Skip to content

Commit

Permalink
ci: rerun failed workflow runs automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Nov 5, 2024
1 parent 28094e9 commit 8859aa7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/auto-rerun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Rerun failed workflow runs automatically
on:
workflow_dispatch: {}
schedule:
- cron: "0 */1 * * *" # Hourly

env:
AQUA_GLOBAL_CONFIG: ${{ github.workspace }}/aqua-all.yaml
AQUA_LOG_COLOR: always
AQUA_CONFIG: ${{ github.workspace }}/aqua/update.yaml

jobs:
rerun:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: write # To rerun a workflow run
contents: read # To checkout a repository
pull-requests: read # To list pull requests
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- run: bash scripts/rerun.sh
env:
GITHUB_TOKEN: ${{github.token}}
24 changes: 24 additions & 0 deletions scripts/rerun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -eu

d=$(date +%Y-%m-%d -d "4 day ago")

shas=$(gh -R aquaproj/aqua-registry pr list \
-A "app/aquaproj-aqua-registry" \
-S "created:>=$d" \
--json headRefOid \
-q '.[].headRefOiddate +%Y:%m:%d -d "1 day ago"')

for sha in $shas; do
echo "sha: $sha" >&2
runids=$(gh -R aquaproj/aqua-registry run list \
-c "$sha" \
-s failure \
--json databaseId \
-q '.[].databaseId')
for runid in $runids; do
echo "runid: $runid" >&2
gh -R aquaproj/aqua-registry run rerun "$runid" --failed
done
done

0 comments on commit 8859aa7

Please sign in to comment.