You've already forked armbian.github.io
mirror of
https://github.com/armbian/armbian.github.io.git
synced 2026-01-06 11:42:20 -08:00
Enable watchdog on several scripts
This commit is contained in:
47
.github/workflows/watchdog.yml
vendored
Normal file
47
.github/workflows/watchdog.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# This action recreate action for building stable images
|
||||
#
|
||||
name: Watchdog (cronjob)
|
||||
on:
|
||||
push:
|
||||
schedule:
|
||||
- cron: '*/15 * * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.ACCESS_TOKEN_ARMBIANWORKER }}
|
||||
|
||||
concurrency:
|
||||
group: watchdog-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
|
||||
gradle:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 8
|
||||
matrix:
|
||||
|
||||
# list scripts you want to watch and execute failed jobs x-times
|
||||
script: ["generate-redirector-config","generate-base-files-info-json"]
|
||||
|
||||
name: rerun
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: "Restart ${{ matrix.script }}.yml"
|
||||
run: |
|
||||
|
||||
# Define variables here
|
||||
OWNER_REPO="armbian/armbian.github.io"
|
||||
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')
|
||||
|
||||
# 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
|
||||
fi
|
||||
Reference in New Issue
Block a user