Outline
I am automating GitHub’s Release Note using Release Drafter
.
This Release Drafter
is based on the Label of GitHub’s PR. Release Drafter
provides a feature to automatically create Labels, and it uses the title of the PR. So, the PR title is important.
Previously, when checking the title of a PR, I used Conventional PR Title Action.
However, in the current monorepo project, the Conventional PR Title Action
was not enough, so I ended up using other GitHub Actions.
In this blog post, I will introduce how to check the title of a PR when creating a PR using action-check-pr-title
.
action-check-pr-title
action-check-pr-title
is a GitHub Actions that checks the title of a PR using regular expressions.
Create GitHub Actions
To create GitHub Actions that check the title of a PR using action-check-pr-title
, create a .github/workflows/check_pr_title.yml
file and modify it as follows.
name: Check PR Title
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
jobs:
check-pr-title:
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Check PR Title
uses: Slashgear/[email protected]
with:
regexp: '(feat|fix|chore|docs|style|refactor|test|build|ci)\((SERVICE1|SERVICE2|template|components|config|common)\): .+'
helpMessage: "Example: 'feat(SERVICE1): example of title'"
Let’s take a closer look at the part that checks the title of the PR.
- name: Check PR Title
uses: Slashgear/[email protected]
with:
regexp: '(feat|fix|chore|docs|style|refactor|test|build|ci)\((SERVICE1|SERVICE2|template|components|config|common)\): .+'
helpMessage: "Example: 'feat(SERVICE1): example of title'"
Here, we use the regexp
option provided by action-check-pr-title
to check the title of the PR
. The regular expression used here allows the following PR titles.
feat(SERVICE1): Add new feature
fix(SERVICE2): Fix bug
refactor(common): Refactor code
...
I developed a monorepo projet, so I set the service name in the Scope
area of Conventional Commits
and set it to check.
Completed
Done! We’ve seen how to check the title of a PR using action-check-pr-title
when creating a PR. Previously, I used Conventional PR Title Action and it also supports regular expression checks, but the settings are not easy, so I decided to use action-check-pr-title
.
So, if you want to check the PR title with regular expressions simply, try using action-check-pr-title
.
Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!
App promotion
Deku
.Deku
created the applications with Flutter.If you have interested, please try to download them for free.