Keep scheduled workflows alive #28
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: "16 07 10 * *" | |
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" && | |
if test "$GITHUB_ACTOR" = nektos/act | |
then | |
echo "Would push commit:" | |
git -P show --stat | |
else | |
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 | |
} | |
fi |