From 8859aa7006e55017bb87b1a48ff04a0a7f5293d9 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Tue, 5 Nov 2024 21:34:17 +0900 Subject: [PATCH] ci: rerun failed workflow runs automatically --- .github/workflows/auto-rerun.yaml | 25 +++++++++++++++++++++++++ scripts/rerun.sh | 24 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/auto-rerun.yaml create mode 100644 scripts/rerun.sh diff --git a/.github/workflows/auto-rerun.yaml b/.github/workflows/auto-rerun.yaml new file mode 100644 index 0000000000..347e3738b7 --- /dev/null +++ b/.github/workflows/auto-rerun.yaml @@ -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}} diff --git a/scripts/rerun.sh b/scripts/rerun.sh new file mode 100644 index 0000000000..c73e6c320d --- /dev/null +++ b/scripts/rerun.sh @@ -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