-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: rerun failed workflow runs automatically (#28473)
* ci: rerun failed workflow runs automatically * ci: remove unnecessary envs * ci: write a script to workflows directly * ci: add a info log * ci: improve logs
- Loading branch information
1 parent
28094e9
commit 12850dc
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
name: Rerun failed workflow runs automatically | ||
on: | ||
workflow_dispatch: {} | ||
schedule: | ||
- cron: "0 */1 * * *" # Hourly | ||
|
||
jobs: | ||
rerun: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
permissions: | ||
actions: write # To rerun workflow runs | ||
pull-requests: read # To list pull requests | ||
steps: | ||
- run: | | ||
set -eu | ||
d=$(date +%Y-%m-%d -d "4 day ago") | ||
info "date: $d" | ||
bot=app/aquaproj-aqua-registry | ||
info "searching pull requests" >&2 | ||
shas=$(gh -R "$GITHUB_REPOSITORY" pr list \ | ||
-A "$bot" \ | ||
-S "created:>=$d" \ | ||
--json headRefOid \ | ||
-q '.[].headRefOid') | ||
for sha in $shas; do | ||
echo "searching workflow runs sha=$sha" >&2 | ||
runids=$(gh -R "$GITHUB_REPOSITORY" run list \ | ||
-c "$sha" \ | ||
-s failure \ | ||
--json databaseId \ | ||
-q '.[].databaseId') | ||
for runid in $runids; do | ||
echo "rerunning a workflow run runid=$runid" >&2 | ||
gh -R "$GITHUB_REPOSITORY" run rerun "$runid" --failed | ||
done | ||
done | ||
env: | ||
GITHUB_TOKEN: ${{github.token}} |