-
Notifications
You must be signed in to change notification settings - Fork 1
37 lines (32 loc) · 1.06 KB
/
keepalive.yaml
File metadata and controls
37 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: keep-actions-alive
on:
workflow_dispatch:
schedule:
- cron: '0 9 * * *'
permissions:
contents: write
jobs:
keepalive:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: main
fetch-depth: 0
- name: Commit empty change if last commit is older than 30 days
shell: bash
run: |
set -euo pipefail
git fetch origin main
last_ts=$(git log -1 --format=%ct origin/main || git log -1 --format=%ct)
now_ts=$(date +%s)
thirty_days=$((30*24*60*60))
if (( now_ts - last_ts > thirty_days )); then
echo "Last commit is older than 30 days. Creating an empty commit..."
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit --allow-empty -m "Keep scheduled Actions alive ($(date -u +%F))"
git push origin HEAD:main
else
echo "Last commit is recent enough; skipping."
fi