[GitHub Actions] Check title of Pull request

[GitHub Actions] Check title of Pull request

2023-05-11 hit count image

Let's see how to use GitHub Actions' Conventional PR Title Action to check whether the title of Pull request is written according to the rules.

Outline

When writing a commit message in Git, there are certain rules. A typical commit message convention is Conventional Commits.

In this blog post, I will introduce how to use Conventional PR Title Action of GitHub Actions to check whether the title of Pull request is according to the Conventional Commits rule.

Blog series

This blog post is a series. You can see the other posts on the link below.

Conventional Commits

Conventional Commits is a convention about the structure of the commit message like the following.

<type>: <description>

<body>

<footer>

In here, Type, Body, and Footer are optional, but usually, when writing a commit message, the following Type is added.

  • fix:: In case of bug fixed.
  • feat:: In case of feature added.
  • build:: In case of build system or dependencies changed.
  • chore:: In case of build system or dependencies changed.
  • ci:: In case of CI configuration or scripts changed.
  • docs:: In case of only documentation changed.
  • style:: In case of code style(space, formatting, colons, etc) changed.
  • refactor:: In case of refactoring code not fixing bugs or adding features.
  • pref:: In case of modifying code for improving performance.
  • test:: In case of adding test code or modifying existing test code.

Conventional PR Title Action

Conventional PR Title Action is a GitHub Actions to check the title of Pull request according to Conventional Commits which is a commit message rule. In other words, it checks the Pull request title to whether including Type of Conventional Commits or not.

To use Conventional PR Title Action for checking the Pull request title, create the .github/workflows/pr-title-checker.yml file and modify it like the following.

name: Check PR title

on:
  pull_request:
    types:
      - opened
      - reopened
      - edited
      - synchronize

jobs:
  lint:
    runs-on: ubuntu-latest
    permissions:
      statuses: write
    steps:
      - uses: aslafy-z/[email protected]
        env:
          GITHUB_TOKEN: $

After adding the GitHub Actions, when Pull request is created or modified, the Pull request title is checked whether including the type of Conventional Commits.

Complete

Done! we’ve seen how to use Conventional PR Title Action of GitHub Actions to check the Pull request title has the type of Conventional Commits. The reason for checking the type like this is for using Release Drafter to automate Release note of GitHub.

If you want to know how to automate Release note of GitHub by using Release Drafter that is one of GitHub Actions, please see the following blog post.

Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!

App promotion

You can use the applications that are created by this blog writer Deku.
Deku created the applications with Flutter.

If you have interested, please try to download them for free.

Posts