From a2944c0d9e2fa6ec2367ed344b8332849f9f30db Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Mon, 16 Dec 2024 16:37:01 +0100 Subject: [PATCH] Cleanup scripts --- .github/workflows/directory-listing.yml | 2 ++ .github/workflows/watchdog.yml | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/directory-listing.yml b/.github/workflows/directory-listing.yml index 19f01035..ecd574ee 100644 --- a/.github/workflows/directory-listing.yml +++ b/.github/workflows/directory-listing.yml @@ -5,6 +5,7 @@ on: jobs: pages-directory-listing: + if: github.ref == 'refs/heads/data' runs-on: ubuntu-latest name: "Directory Listings Index" steps: @@ -24,6 +25,7 @@ jobs: path: 'data' # upload generated folder deploy: + if: github.ref == 'refs/heads/data' needs: pages-directory-listing permissions: pages: write # to deploy to Pages diff --git a/.github/workflows/watchdog.yml b/.github/workflows/watchdog.yml index 6025abba..9dd22aa3 100644 --- a/.github/workflows/watchdog.yml +++ b/.github/workflows/watchdog.yml @@ -1,5 +1,5 @@ # -# This action recreate action for building stable images +# This action restarts actions that failed - 3x # name: Watchdog (cronjob) on: @@ -8,9 +8,6 @@ on: - cron: '*/15 * * * *' workflow_dispatch: -env: - GH_TOKEN: ${{ secrets.ACCESS_TOKEN_ARMBIANWORKER }} - concurrency: group: watchdog-${{ github.ref }} cancel-in-progress: true @@ -24,9 +21,11 @@ jobs: matrix: # list scripts you want to watch and execute failed jobs x-times - script: ["generate-redirector-config","generate-base-files-info-json"] + script: + - generate-redirector-config + - generate-base-files-info-json - name: rerun + name: "R" runs-on: ubuntu-latest steps: @@ -38,10 +37,10 @@ jobs: ATTEMPTS="3" SCRIPT="${{ matrix.script }}" - WORKFLOW=$(gh api "/repos/${OWNER_REPO}/actions/workflows" | jq '.workflows[] | select(.path==".github/workflows/'${{ matrix.script }}'.yml")' | jq -r '.id') - read ID STATUS ATTEMPT <<< $(gh api "/repos/${OWNER_REPO}/actions/workflows/${WORKFLOW}/runs" | jq '.workflow_runs[]' | jq -r '.id,.conclusion,.run_attempt' | head -3 | xargs -n3 -d'\n') + WORKFLOW=$(gh api "/repos/${{ github.repository }}/actions/workflows" | jq '.workflows[] | select(.path==".github/workflows/'${{ matrix.script }}'.yml")' | jq -r '.id') + read ID STATUS ATTEMPT <<< $(gh api "/repos/${{ github.repository }}/actions/workflows/${WORKFLOW}/runs" | jq '.workflow_runs[]' | jq -r '.id,.conclusion,.run_attempt' | head -3 | xargs -n3 -d'\n') # if attempt is lower then 5 and status is "cancelled" or "failed", rerun failed jobs if [ "${ATTEMPT}" -lt "${ATTEMPTS}" ] && ([ "$STATUS" == "failure" ] || [ "$STATUS" == "failure" ]); then - gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${OWNER_REPO}/actions/runs/${ID}/rerun-failed-jobs + gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.repository }}/actions/runs/${ID}/rerun-failed-jobs fi