Keep scheduled workflows alive #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Keep scheduled workflows alive | |
on: | |
schedule: | |
- cron: "23 19 17 * *" # 7:23pm on every 17th of the month | |
workflow_dispatch: | |
jobs: | |
job: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: 'true' | |
- name: Create and push a commit | |
env: | |
GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@github'" | |
run: | | |
mkdir -p .github/cached | |
file='.github/cached/keepalive.txt' | |
date >$file | |
git add "$file" | |
git commit -m "workflow keepalive" && | |
git push origin HEAD </dev/null || { | |
for i in 1 2 3 4 5 | |
do | |
# In case of concurrent pushes, let's pull and push | |
git pull origin $GITHUB_REF </dev/null || exit 1 | |
git push origin HEAD </dev/null && exit 0 | |
done | |
exit 1 | |
} |