From bb543e2c653caad193db1698d7ccc7e4f35058e2 Mon Sep 17 00:00:00 2001 From: Florian Wilhelm <2292245+fwilhe@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:26:51 +0200 Subject: [PATCH] Retry failed repo builds (#21) We had failed repo builds quite often recently which causes manual effort. Let's try to mitigate this using retry logic. Taken from https://github.com/gardenlinux/repo-debian-snapshot/tree/main/.github/workflows Fixes https://github.com/gardenlinux/gardenlinux/issues/2288 (hopefully) --- .github/workflows/build.yml | 10 ++++++++++ .github/workflows/rerun-build.yml | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .github/workflows/rerun-build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05b952f..fbff945 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,3 +129,13 @@ jobs: build /create_dist /repo today 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' aws s3 cp --recursive 'repo/dists/today' 's3://${{ vars.S3_BUCKET }}/gardenlinux/dists/today' aws cloudfront create-invalidation --distribution-id '${{ secrets.CLOUDFRONT_DISTRIBUTION }}' --paths '/gardenlinux/dists/today/*' + # Attempt to make CI more resilient using retry logic https://github.com/gardenlinux/gardenlinux/issues/2288 + re-run: + needs: [ build ] + if: failure() && fromJSON(github.run_attempt) < 3 + runs-on: ubuntu-latest + steps: + - env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ github.token }} + run: gh workflow run rerun-build.yml -F run_id=${{ github.run_id }} diff --git a/.github/workflows/rerun-build.yml b/.github/workflows/rerun-build.yml new file mode 100644 index 0000000..a2604cc --- /dev/null +++ b/.github/workflows/rerun-build.yml @@ -0,0 +1,17 @@ +name: re-run build +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 }} + run: | + gh run watch ${{ inputs.run_id }} > /dev/null 2>&1 + gh run rerun ${{ inputs.run_id }} --failed