I'm trying to get ahead on the Action Spotlight series, and needed a way to write and stage a post in advance of it's Friday publication date.
So, this week's post covers an action that I needed automatically merge the pull request containing this blog post -
What does it do?
Merge Schedule allows you to merge pull requests at a scheduled time. The most common use case that I’ve seen for this so far is to merge content into a static site (like this one) at some point in the future.
Scheduled pull requests allows you to stage and approve content ahead of time and have it automatically merged (and deployed if you have a pipeline set up) automatically.
How does it work?
There are two separate handlers in
merge-schedule-action. The first handles a
synchronize-d, and the second is run when triggered on a
It’s important to note that you cannot schedule merges from forks.
pull_request handler is a really useful addition to the action. Whenever a PR is opened it checks if the body contains a
/schedule command. If it does, a check is added using the
- If the date provided to
/scheduleis invalid, a
failurecheck is added to the PR to indicate that something is wrong, allowing the author to fix the date.
- If the provided date is in the past, a
failurecheck is added to the PR (but will still be merged by the
- Otherwise, create an
in_progresscheck which prevents the PR being merged (unless you’re an admin)
This is where the bulk of the work happens. This method is triggered on a schedule that you set in your workflow. You can choose any schedule you like, but I’d recommend hourly (if you set specific publish times) or once per day (if you only set a publish date).