Labeling GitHub auto-merge pull requests

Sven Bendel
3 min readSep 17, 2022

--

Photo by Roman Synkevych 🇺🇦 on Unsplash

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:

GitHub pull request overview

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.

GitHub pull request overview with auto-merge labels

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:

  1. Create a new workflow file in your repository, usually under .github/workflows. You can give it any name, e.g. automerge-labeler.yml.
  2. The content of the file should be something like the following:

What this configuration file instructs the workflow to do is:

  1. Monitor all pull requests for enable or disable auto-merge events.
  2. Instruct the automerge-labeler action to (un-)label those pull requests with auto-merge.

Commit and push and boom! 💥 All auto-merge pull-requests will now automatically be labeled!

Our action bot has added the auto-merge label after we have enabled auto-merge

--

--

Sven Bendel
Sven Bendel

Written by Sven Bendel

Senior Android Engineer @Photoroom. Founder. Crowdfunding addict. Trying hard to do the right thing and failing more often than not. https://proven.lol/286e9b

No responses yet