GitHub Action : conventional-commit-checker

4 min readJun 4, 2020

In this article, we will see how to write a GitHub Action and publish it to Github marketplace. GitHub Actions are GitHubs solution for CI/CD automation. This article was not my primary intention since I thought I could use something available on the GitHub market place, but as I was searching for different GitHub apps and actions on GitHub market place, I found some actions/apps that are similar I could not find the one the “exactly” fit my need.

So I want a GitHub action that checks for conventional commit format in Pull Requests.

Conventional commit in short has this below format

<type>[optional scope]: <description>

[optional body]

[optional footer]

My GitHub Actions goals are

  1. Check the Pull Request title for conformance of <type>[optional scope]: <description>
  2. Check the description of the Pull request for conformance of[optional body] and [optional footer]
  3. When PR is accepted, it should squash all the commits in the PR and the commit message should have the PR title, description, body and footer

Following the instructions from , I got a hello world action working.

Step 1: It uses the actions/checkout@v2 which as the name implies git clone/checkouts our repo into the machine where this action is running. This action is prerequisite for all actions. You can do some advanced stuff with checkout other repos for complex builds.

Step 2: (Say Hello go <who-to-greet>): uses the following action code. <who-to-greet> is an input variable to this action.

name: 'Hello World'
description: 'Greet someone and record the time'
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
time: # id of output
description: 'The time we greeted you'
using: 'node12'
main: 'dist/index.js'

The Github action executes a javascript index.js file which takes the input paramenter who-to-greet , greets and also sets an output time variable

const core = require('@actions/core');
const github =…

Solving Problems. Making Software Better. Intrigued by Elegant Solutions.