Labeling GitHub auto-merge pull requests
It’s that time of the year where many of us revise their workflows and try to optimise. And boy, there is always quite a lot to improve!
This time my GitHub workflow was ripe for a productivity check. Something, that I always found cumbersome since the inception of the amazing GitHub auto-merge feature was, that you couldn’t see whether a pull request was due for auto-merge or not in the pull request overview page:
For everyone who doesn’t know auto-merge: it essentially allows you to tell GitHub to merge a pull request as soon as all checks are green. Usually this means after the CI has successfully build the branch and all checks have passed. No more waiting for that little checkmark to turn green to be able to press the merge button! ✅
Even when working alone on a repository there can be quite a lot of (automated) pull requests with tools like Dependabot and the likes.
When it’s review and merging time, for me that usually means lots of unnecessary clicking on yellow state (that is in progress of being checked) pull requests which actually were already queued up for auto-merging — thanks for nothing, bad short-term memory! 🤯
A simple way to improve this is labeling pull requests for which auto-merge had been enabled previously which makes those PRs easy to spot and simple to filter in the pull request overview.
Turns out, that’s super easy to do with GitHub actions! And to make it even simpler for you, I’ve packaged this into an action ready to be used via the Github marketplace:
You can integrate this into your repository with a straightforward 2-step process:
- Create a new workflow file in your repository, usually under
.github/workflows
. You can give it any name, e.g.automerge-labeler.yml
. - The content of the file should be something like the following:
What this configuration file instructs the workflow to do is:
- Monitor all pull requests for enable or disable auto-merge events.
- Instruct the
automerge-labeler
action to (un-)label those pull requests withauto-merge
.
Commit and push and boom! 💥 All auto-merge pull-requests will now automatically be labeled!