Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/cached/keepalive.txt

This file was deleted.

45 changes: 27 additions & 18 deletions .github/workflows/keepalive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,12 @@ jobs:
git fetch https://github.com/gitgitgadget/gitgitgadget-workflows HEAD &&
if test 0 = $(git rev-list --count HEAD..FETCH_HEAD)
then
exit 0 # let the next step create a commit
exit 0 # nothing to merge
fi &&
git merge --no-edit FETCH_HEAD &&
echo "result=merged" >>$GITHUB_OUTPUT
- name: Create a commit
id: commit
if: steps.merge.outputs.result != 'merged'
run: |
if test workflow_dispatch != '${{ github.event_name }}' &&
test 0 -lt $(git rev-list --count --since=3.weeks.ago HEAD)
then
echo "::notice::No need to keep alive, there were commits in the last three weeks"
echo "result=skip-push" >>$GITHUB_OUTPUT
exit 0
fi &&
mkdir -p .github/cached
file='.github/cached/keepalive.txt'
date >$file
git add "$file"
git commit -m "workflow keepalive"
- name: Push changes
if: steps.commit.outputs.result != 'skip-push'
if: steps.merge.outputs.result == 'merged'
run: |
git push origin HEAD </dev/null || {
for i in 1 2 3 4 5
Expand All @@ -57,3 +41,28 @@ jobs:
done
exit 1
}
- name: Obtain a token to reset the inactivity timer
uses: actions/create-github-app-token@v3
id: token
with:
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
- name: Reset the 60-day inactivity timer of every active workflow
env:
GH_TOKEN: ${{ steps.token.outputs.token }}
REPO: ${{ github.repository }}
run: |
ret=0
gh api "/repos/$REPO/actions/workflows" --paginate \
--jq '.workflows[] | select(.state == "active") | .path' |
while read -r path
do
name=${path##*/}
echo "Refreshing $name"
gh workflow -R "$REPO" disable "$name" &&
gh workflow -R "$REPO" enable "$name" || {
echo "::error::could not refresh $name; please ensure that it is enabled!" >&2
ret=1
}
done
exit $ret