Skip to content

shenxianpeng/commit-check-action

 
 

Repository files navigation

Commit-Check GitHub Action

Main Commit Check GitHub release (latest SemVer) Used by GitHub marketplace

A Github Action for checking commit message formatting, branch naming, committer name, email, commit signoff and more.

Usage

Create a new GitHub Actions workflow in your project, e.g. at .github/workflows/commit-check.yml

name: Commit Check

on:
  push:
  pull_request:
    branches: 'main'

jobs:
  commit-check:
    runs-on: ubuntu-latest
    permissions:  # use permissions because of use pr-comments
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}  # checkout PR HEAD commit
      - uses: commit-check/commit-check-action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # use GITHUB_TOKEN because of use pr-comments
        with:
          message: true
          branch: true
          author-name: true
          author-email: true
          commit-signoff: true
          job-summary: true
          pr-comments: ${{ github.event_name == 'pull_request' }}

Optional Inputs

message

  • Description: check commit message formatting convention.
  • Default: 'true'

branch

  • Description: check git branch naming convention.
  • Default: 'true'

author-name

  • Description: check committer author name
  • Default: 'true'

author-email

  • Description: check committer author email
  • Default: 'true'

commit-signoff

  • Description: check committer commit signature
  • Default: 'true'

dry-run

  • Description: run checks without failing. exit code is 0 otherwise is 1.
  • Default: 'false'

job-summary

  • Description: display job summary to the workflow run
  • Default: 'true'

pr-comments

  • Description: post results to the pull request comments
  • Default: 'true'

Important

This is a experimental feature use it you need to set GITHUB_TOKEN in the GitHub Action.

Note: the default rule of above inputs is following this configuration, if you want to customize just add your .commit-check.yml config file under your repository root directory.

GitHub Action job summary

By default, commit-check-action results are shown on the job summary page of the workflow.

Success job summary

Success job summary

Failure job summary

Failure job summary

GitHub Pull Request comments

Success pull request comment

Success pull request comment

Failure pull request comment

Failure pull request comment

Badging your repository

You can add a badge to your repository to show your contributors / users that you use commit-check!

Commit Check

Markdown

[![Commit Check](https://github.com/commit-check/commit-check-action/actions/workflows/commit-check.yml/badge.svg)](https://github.com/commit-check/commit-check-action/actions/workflows/commit-check.yml)

reStructuredText

.. image:: https://github.com/commit-check/commit-check-action/actions/workflows/commit-check.yml/badge.svg
    :target: https://github.com/commit-check/commit-check-action/actions/workflows/commit-check.yml
    :alt: Commit Check

Versioning

Versioning follows Semantic Versioning.

Have question or feedback?

To provide feedback (requesting a feature or reporting a bug) please post to issues.

About

Commit Check GitHub Action

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages

  • Python 100.0%