Skip to content

Git Commit Check

Actions

About

Git commit check based on certain rules
v3.0.0
Latest
Star (1)

GitCC GitHub Action

maintained Programming Language License: MIT

GitHub Marketplace

GitCC checks commit messages for certain rules. Available for GitHub Actions and Forgejo Actions.

The action is completely written in typescript and runs on Node 24.

A CLI version is also available at GitHub.

Usage

On Forgejo: https://github.com/IceflowRE/gitcc@v3.0.0
On GitHub: IceflowRE/gitcc@v3.0.0

Note

Both exact tags (v3.0.0) and the rolling tag (v3) are available. For security reasons, using exact tags is recommended, as rolling tags can be silently changed to point to a different commit.

Minimal example:

- uses: IceflowRE/gitcc@v3.0.0
  with:
    validator: "regex"
    options: |
      summary: ".*"
      description: ".*"

All options:

- uses: IceflowRE/gitcc@v3.0.0
  with:
    # Filepath to a validator file, relative to the root of the repository.
    validator_file: ""
    # Name of builtin validator: 'regex', 'simpletag'
    validator: ""
    # Each line is a separate option passed to the validator (key: "value").
    options: |
      opt1: "val1"
      opt2: "val2"
    # Platform to use: 'github' or 'forgejo'. If empty it will be automatically detected.
    platform: ""
    # GitHub / Forgejo token. This is set automatically, normally there is no need to set this.
    token: ${{ github.token }}

Warning

If you require the FORGEJO_TOKEN environment variable and run on GitHub, set platform to github to avoid errors.

Builtin validators

SimpleTag

Format: [<tag>] <Good Description> (e.g. [ci] Fix testing suite installation)

RegEx

- uses: IceflowRE/gitcc@v3.0.0
  with:
    validator: "regex"
    options: |
      summary: ".*"
      description: ".*"

Custom validators

Custom validators can be written in Javascript and placed as a plain file in your repository. Just use the path as a value for validator_file.

- uses: IceflowRE/gitcc@v3.0.0
  with:
    validator_file: ".github/workflows/myvalidator.mjs"
    options: |
      key1: "val1"
      key2: "val2"

The file has to export a function createValidator that returns an object with a function validate(commit). This function will be called for each commit and should return a Result object with the validation result.

import * as gitcc from "gitcc"

export function createValidator(options) {
    return {
        validate(commit) {
            return gitcc.valid()
        }
    }
}

A full example can be found here.

Helper functions are available in the gitcc module. Import with import * as gitcc from "gitcc". gitcc is a virtual module provided by the action, no installation or setup required.

  • function invalid(message: string, commit?: Commit): Result
    Helper function to create a Result with status Status.Invalid.
  • function valid(commit?: Commit): Result
    Helper function to create a Result with status Status.Valid.
  • function warning(message: string, commit?: Commit): Result
    Helper function to create a Result with status Status.Warning.
  • function splitCommitMessage(msg: string): [string, string]
    Helper function to split a commit message into summary and description.

Reference

export interface User {
    email?: string
    name?: string
    username?: string
}

export interface Commit {
    author?: User
    committer?: User
    distinct?: boolean
    hexsha?: string
    timestamp?: Date
    // the full commit message, including summary and description.
    message?: string
}

Changelog

3.0.0

  • Enable immutable releases.
  • Refactor codebase to be more maintainable and extensible.
  • Simplify custom scripts.

Migration

If you used custom validators, you have to read the custom validator section and adapt your scripts. The scripts got simplified and migration should be straightforward with minimal changes.

2.1.0

  • Running on Node 24 in GitHub Actions.

License

Copyright 2021-present Iceflower S (iceflower@iceflower.eu)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Git Commit Check is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Git commit check based on certain rules
v3.0.0
Latest

Git Commit Check is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.