File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ #
2
+ # This action recreate action for building stable images
3
+ #
4
+ name : Watchdog (cronjob)
5
+ on :
6
+ push :
7
+ schedule :
8
+ - cron : ' */15 * * * *'
9
+ workflow_dispatch :
10
+
11
+ env :
12
+ GH_TOKEN : ${{ secrets.ACCESS_TOKEN_ARMBIANWORKER }}
13
+
14
+ concurrency :
15
+ group : watchdog-${{ github.ref }}
16
+ cancel-in-progress : true
17
+
18
+ jobs :
19
+
20
+ gradle :
21
+ strategy :
22
+ fail-fast : false
23
+ max-parallel : 8
24
+ matrix :
25
+
26
+ # list scripts you want to watch and execute failed jobs x-times
27
+ script : ["generate-redirector-config","generate-base-files-info-json"]
28
+
29
+ name : rerun
30
+ runs-on : ubuntu-latest
31
+ steps :
32
+
33
+ - name : " Restart ${{ matrix.script }}.yml"
34
+ run : |
35
+
36
+ # Define variables here
37
+ OWNER_REPO="armbian/armbian.github.io"
38
+ ATTEMPTS="3"
39
+ SCRIPT="${{ matrix.script }}"
40
+
41
+ WORKFLOW=$(gh api "/repos/${OWNER_REPO}/actions/workflows" | jq '.workflows[] | select(.path==".github/workflows/'${{ matrix.script }}'.yml")' | jq -r '.id')
42
+ 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')
43
+
44
+ # if attempt is lower then 5 and status is "cancelled" or "failed", rerun failed jobs
45
+ if [ "${ATTEMPT}" -lt "${ATTEMPTS}" ] && ([ "$STATUS" == "failure" ] || [ "$STATUS" == "failure" ]); then
46
+ 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
47
+ fi
You can’t perform that action at this time.
0 commit comments