Skip to content

Conversation

Copy link

Copilot AI commented Jan 29, 2026

GitHub disables scheduled workflows after 60 days of repository inactivity. This workflow prevents deactivation.

Implementation

  • Monthly cron check (1st of month) - must run within 60 days or workflow disables itself
  • Checks last commit date on default branch
  • If inactive >30 days: creates/updates draft PR with empty commits on persistent keep-alive-workflow branch
  • If active: no-op

Why empty commits

Empty commits generate activity without modifying repository content. The draft PR is reopened/closed to register activity.

# Runs monthly, must execute within 60 days
schedule:
  - cron: "0 0 1 * *"

Fully automated. No human intervention required.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 29, 2026 17:21
Co-authored-by: TimHess <3947063+TimHess@users.noreply.github.com>
Co-authored-by: TimHess <3947063+TimHess@users.noreply.github.com>
…umentation

Co-authored-by: TimHess <3947063+TimHess@users.noreply.github.com>
Co-authored-by: TimHess <3947063+TimHess@users.noreply.github.com>
Copilot AI changed the title [WIP] Add job to keep repository alive via scheduled trigger Add automated keep-alive workflow for scheduled jobs Jan 29, 2026
Copilot AI requested a review from TimHess January 29, 2026 17:26
@TimHess
Copy link
Member

TimHess commented Jan 29, 2026

@copilot I didn't realize opening and closing a PR would be a viable solution here - can it be the same PR (or issue) that's closed/open/modified? If we could edit or open/close the same PR it would be even less of a hassle. Also, this process doesn't appear to require human intervention, so we can run it every 59 days and forget about the buffer window

Co-authored-by: TimHess <3947063+TimHess@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 29, 2026

@copilot I didn't realize opening and closing a PR would be a viable solution here - can it be the same PR (or issue) that's closed/open/modified? If we could edit or open/close the same PR it would b...

Yes, great suggestions! I've updated the workflow to:

  1. Reuse the same PR: Uses a persistent branch (keep-alive-workflow) and the same PR that gets reopened/closed each time. Much cleaner than creating new PRs.

  2. Run every ~59 days: Changed from monthly to cron: "0 0 1 */2 *" (every 2 months = ~59-62 days). Since this requires no human intervention, we don't need the extra buffer.

The workflow now:

  • Creates one persistent branch and PR on first run
  • Every ~59 days: reopens the PR (if closed) then immediately closes it with a timestamp comment
  • Zero noise after initial setup

Commit: cfa441d

@TimHess TimHess marked this pull request as ready for review January 30, 2026 21:19
@TimHess TimHess marked this pull request as draft January 30, 2026 21:20
@TimHess TimHess marked this pull request as ready for review February 2, 2026 22:28
@TimHess TimHess requested a review from bart-vmware February 2, 2026 22:29
Comment on lines 8 to 12
# 1. Runs on the first day of every month
# 2. Checks if the keep-alive PR exists
# 3. If PR doesn't exist, creates it with a persistent branch
# 4. Reopens the PR (if closed) and immediately closes it again
# 5. This activity prevents workflow deactivation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the PR_BODY below don't indicate that an empty commit is being pushed.

Co-authored-by: TimHess <3947063+TimHess@users.noreply.github.com>
Copilot AI changed the title Add automated keep-alive workflow for scheduled jobs Document critical constraint: keep-alive workflow must run every 30 days Feb 3, 2026
@TimHess TimHess changed the title Document critical constraint: keep-alive workflow must run every 30 days add keep-alive workflow Feb 3, 2026
Co-authored-by: TimHess <3947063+TimHess@users.noreply.github.com>
Copilot AI changed the title add keep-alive workflow Reduce workflow verbosity and create draft PRs Feb 3, 2026
Copilot AI changed the title Reduce workflow verbosity and create draft PRs Keep scheduled workflows alive Feb 3, 2026
@TimHess TimHess requested a review from bart-vmware February 3, 2026 20:58
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
# Skip keep-alive if repository has been active in last 30 days
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Skip keep-alive if repository has been active in last 30 days
# Determine if the repository has been active in the last 30 days.

Or remove this comment entirely, as the step name already indicates it.

Comment on lines +55 to +56

echo "Days since last activity: $days_diff"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "Days since last activity: $days_diff"
echo "Days since last activity: $days_diff"

gh pr create \
--draft \
--head "$branch_name" \
--base ${{ github.event.repository.default_branch }} \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step above has a fallback to main, which doesn't appear here. Is it redundant?

pr_state=$(gh pr view "$pr_number" --json state --jq '.state')
echo "PR #$pr_number is $pr_state"

if [ "$pr_state" = "CLOSED" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no bash expert, but this looks like an assignment to me. According to https://stackoverflow.com/a/4277753, the typical syntax uses double brackets:

if [[ "$pr_state" == "CLOSED" ]]

if [ "$pr_state" = "CLOSED" ]; then
echo "Reopening PR #$pr_number"
gh pr reopen "$pr_number"
sleep 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to sleep?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants