Skip to content

Github Action to check if the commit follows proper syntax 😉

License

Notifications You must be signed in to change notification settings

adityaa30/check-commit

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Actions status

Check Commit Message

Action to check if the commit follows proper guidelines as specified here

Usage

Create a workflow .yml file in your repositories .github/workflows directory (eg. .github/workflows/check-commit.yml). In your workflow you first need to checkout your repository then use this action.

Refer to the example below,

name: Check Commit Message

on: [pull_request, push]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout 🛎️
        uses: actions/checkout@v2

      - name: Check commit 🧪
        uses: adityaa30/check-commit@master

Input Parameters

  • compulsory-scope

    • Either 'true' or 'false'
    • Defaults to 'false'
    • If true, scope field becomes compulsory for each commit (refer here)
  • max-header-length

    • Should be a valid non-zero positive integer
    • Defaults to 50
    • Raises an error if length of commit header is more than specified

Project Installation

Fork the repository

# Clone the forked repository
git clone https://github.com/<git-username>/check-commit.git

# Enter project directory
cd check-commit

# Install dependencies
npm install

# Build the project
npm run build

NOTE

  • Before pushing any changes, please build the project to update the dist/index.js in order to reflect your changes in github
  • To test the project in your local use act

TODO

  • Get the commit message
  • Implement rules based on syntax defined here
  • Helper functions to check commit message based on rules
  • Add input parameter compulsory-scope
  • Add input parameter max-header-length
  • Add a CLI
  • Add custom input parameters