Skip to content

Commit

Permalink
Cleanup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Dec 16, 2024
1 parent d89ba9e commit 061a67e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/directory-listing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

jobs:
pages-directory-listing:
if: github.ref == 'refs/heads/data'
runs-on: ubuntu-latest
name: "Directory Listings Index"
steps:
Expand All @@ -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
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/watchdog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This action recreate action for building stable images
# This action restarts actions that failed - 3x
#
name: Watchdog (cronjob)
on:
Expand All @@ -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
Expand All @@ -24,10 +21,12 @@ 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
runs-on: ubuntu-latest
name: "R"
runs-on: ubuntu-24.04
steps:

- name: "Restart ${{ matrix.script }}.yml"
Expand All @@ -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

0 comments on commit 061a67e

Please sign in to comment.