|
4 | 4 | # GitHub automatically disables scheduled workflows after 60 days of repository inactivity. |
5 | 5 | # This workflow prevents that by creating minimal activity when needed. |
6 | 6 | # |
| 7 | +# Important Constraint: |
| 8 | +# This workflow MUST run at least every 60 days. If it doesn't run for 60 days, GitHub will |
| 9 | +# disable it permanently and it won't be able to run itself anymore. Therefore, we schedule |
| 10 | +# it to run every 30 days (monthly) to ensure it always stays active, even if there are |
| 11 | +# holidays, weekends, or workflow execution delays. |
| 12 | +# |
7 | 13 | # How it works: |
8 | | -# 1. Runs on the first day of every month |
9 | | -# 2. Checks if the keep-alive PR exists |
10 | | -# 3. If PR doesn't exist, creates it with a persistent branch |
11 | | -# 4. Reopens the PR (if closed) and immediately closes it again |
12 | | -# 5. This activity prevents workflow deactivation |
| 14 | +# 1. Runs on the first day of every month (~30 days) |
| 15 | +# 2. Checks if there's been activity in the last 30 days (commits on default branch) |
| 16 | +# 3. If no recent activity, creates/updates a persistent keep-alive PR: |
| 17 | +# - Creates a keep-alive branch (if it doesn't exist) |
| 18 | +# - Adds an empty commit to the branch |
| 19 | +# - Opens/reopens the PR and immediately closes it |
| 20 | +# 4. If recent activity exists, skips the keep-alive action to reduce noise |
13 | 21 | # |
14 | 22 | # Manual trigger: |
15 | 23 | # This workflow can also be triggered manually via workflow_dispatch if needed. |
16 | 24 | name: Keep Scheduled Workflows Alive |
17 | 25 |
|
18 | 26 | on: |
19 | 27 | schedule: |
| 28 | + # Run on the 1st of every month (approximately every 30 days) |
| 29 | + # IMPORTANT: This MUST run at least every 60 days. If 60 days pass without running, |
| 30 | + # GitHub will disable this workflow and it won't be able to run itself anymore. |
| 31 | + # Running monthly (every ~30 days) ensures this never happens. |
20 | 32 | - cron: "0 0 1 * *" |
21 | 33 | workflow_dispatch: |
22 | 34 |
|
|
44 | 56 | shell: bash |
45 | 57 | run: | |
46 | 58 | # Check if the repository has been active in the last 30 days |
47 | | - # We check the default branch for recent commits |
| 59 | + # If there's been recent activity, we skip the keep-alive action to reduce noise. |
| 60 | + # We check the default branch for recent commits. |
48 | 61 |
|
49 | 62 | DEFAULT_BRANCH="${{ github.event.repository.default_branch }}" |
50 | 63 | if [ -z "$DEFAULT_BRANCH" ]; then |
|
64 | 77 |
|
65 | 78 | echo "Days since last activity: $days_diff" |
66 | 79 |
|
67 | | - # Threshold: 30 days (Run monthly, so if no activity in last month, we should act) |
| 80 | + # Threshold: 30 days |
| 81 | + # Since this workflow runs monthly, if there's been activity in the last 30 days, |
| 82 | + # we don't need to create additional keep-alive activity. |
68 | 83 | if [ "$days_diff" -lt 30 ]; then |
69 | 84 | echo "Repository is active enough (less than 30 days since last commit). No keep-alive action needed." |
70 | 85 | echo "run_keep_alive=false" >> $GITHUB_OUTPUT |
|
0 commit comments