-
Notifications
You must be signed in to change notification settings - Fork 2
Keep scheduled workflows alive #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: TimHess <[email protected]>
Co-authored-by: TimHess <[email protected]>
…umentation Co-authored-by: TimHess <[email protected]>
Co-authored-by: TimHess <[email protected]>
|
@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 <[email protected]>
Yes, great suggestions! I've updated the workflow to:
The workflow now:
Commit: cfa441d |
- bump a couple other action refs - whitespace cleanup
.github/workflows/keep-alive.yml
Outdated
| # 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 |
There was a problem hiding this comment.
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 <[email protected]>
Co-authored-by: TimHess <[email protected]>
| GH_TOKEN: ${{ github.token }} | ||
| shell: bash | ||
| run: | | ||
| # Skip keep-alive if repository has been active in last 30 days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # 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.
|
|
||
| echo "Days since last activity: $days_diff" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 }} \ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
GitHub disables scheduled workflows after 60 days of repository inactivity. This workflow prevents deactivation.
Implementation
keep-alive-workflowbranchWhy empty commits
Empty commits generate activity without modifying repository content. The draft PR is reopened/closed to register activity.
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.