@@ -2,29 +2,50 @@ name: Keep scheduled workflows alive
22
33on :
44 schedule :
5- - cron : " 23 19 17 * *" # 7:23pm on every 17th of the month
5+ - cron : " 23 19 3, 17 * *" # 7:23pm on every 3rd and 17th of the month
66 workflow_dispatch :
77
8+ env :
9+ GIT_CONFIG_PARAMETERS : " 'user.name=CI' 'user.email=ci@github'"
10+
811jobs :
912 job :
1013 runs-on : ubuntu-latest
11- strategy :
12- fail-fast : false
1314 permissions :
1415 contents : write
1516 steps :
1617 - uses : actions/checkout@v4
1718 with :
1819 persist-credentials : ' true'
19- - name : Create and push a commit
20- env :
21- GIT_CONFIG_PARAMETERS : " 'user.name=CI' 'user.email=ci@github'"
20+ - name : Merge the upstream default branch
21+ id : merge
22+ if : github.event.repository.fork == true
23+ run : |
24+ git fetch https://github.com/gitgitgadget/gitgitgadget-workflows HEAD &&
25+ if test 0 = $(git rev-list --count HEAD..FETCH_HEAD)
26+ then
27+ exit 0 # let the next step create a commit
28+ fi &&
29+ git merge --no-edit FETCH_HEAD &&
30+ echo "result=merged" >>$GITHUB_OUTPUT
31+ - name : Create a commit
32+ id : commit
33+ if : steps.merge.outputs.result != 'merged'
2234 run : |
35+ if test 0 -lt $(git rev-list --count --since=3.weeks.ago HEAD)
36+ then
37+ echo "::notice::No need to keep alive, there were commits in the last three weeks"
38+ echo "result=skip-push" >>$GITHUB_OUTPUT
39+ exit 0
40+ fi &&
2341 mkdir -p .github/cached
2442 file='.github/cached/keepalive.txt'
2543 date >$file
2644 git add "$file"
27- git commit -m "workflow keepalive" &&
45+ git commit -m "workflow keepalive"
46+ - name : Push changes
47+ if : steps.commit.outputs.result != 'skip-push'
48+ run : |
2849 git push origin HEAD </dev/null || {
2950 for i in 1 2 3 4 5
3051 do
0 commit comments