Skip to content

Commit 0218b76

Browse files
committed
keepalive: avoid creating commits when the branch is already alive enough
If there has been activity over the past three weeks, let's avoid adding more activity: The scheduled workflows will remain enabled even without that keepalive commit. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 36fe012 commit 0218b76

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

.github/workflows/keepalive.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,22 @@ jobs:
2929
git merge --no-edit FETCH_HEAD &&
3030
echo "result=merged" >>$GITHUB_OUTPUT
3131
- name: Create a commit
32+
id: commit
3233
if: steps.merge.outputs.result != 'merged'
3334
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 &&
3441
mkdir -p .github/cached
3542
file='.github/cached/keepalive.txt'
3643
date >$file
3744
git add "$file"
3845
git commit -m "workflow keepalive"
3946
- name: Push changes
47+
if: steps.commit.outputs.result != 'skip-push'
4048
run: |
4149
git push origin HEAD </dev/null || {
4250
for i in 1 2 3 4 5

0 commit comments

Comments
 (0)