@@ -2,29 +2,50 @@ name: Keep scheduled workflows alive
2
2
3
3
on :
4
4
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
6
6
workflow_dispatch :
7
7
8
+ env :
9
+ GIT_CONFIG_PARAMETERS : " 'user.name=CI' 'user.email=ci@github'"
10
+
8
11
jobs :
9
12
job :
10
13
runs-on : ubuntu-latest
11
- strategy :
12
- fail-fast : false
13
14
permissions :
14
15
contents : write
15
16
steps :
16
17
- uses : actions/checkout@v4
17
18
with :
18
19
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'
22
34
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 &&
23
41
mkdir -p .github/cached
24
42
file='.github/cached/keepalive.txt'
25
43
date >$file
26
44
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 : |
28
49
git push origin HEAD </dev/null || {
29
50
for i in 1 2 3 4 5
30
51
do
0 commit comments