Git Product home page Git Product logo

ensure-conventional-commits-gh-action's Introduction

ensure-conventional-commits-gh-action

This action checks that ALL commits present in a pull request follow conventional-commits. Here you have an example of a complete workflow:

name: CI
on:
  pull_request:
    branches: ["main"]
jobs:
  check-conventional-commits:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: ohpensource/[email protected]
        name: Ensure conventional commits
        with:
          settings-file: cicd/settings.json

The main parameter is the settings-file, it is OPTIONAL and it is the path to a JSON file where you can provide the next settings:

  • Custom conventional commits settings (key: conventionalCommits).
    • List of prefixes that commits must start with. Examples: break,feat,fix
    • A prefix must contain only letters and numbers.
    • For every prefix, the release type based on the semantic versioner must be provided. Valid values are: major,minor,patch,none. key: release
  • Scopes list (key: scopes):
    • Scopes provided in the commits will be validated against the list provided.
    • Scope keys must only contain letters, numbers, dashes and underscores.
    • Folder patterns for every scope to ensure commits modify the right files. key: folderPattern

Here is an example of a settings-file:

{
    "conventionalCommits": {
        "break": {
            "release": "major"
        },
        "feat": {
            "release": "minor"
        },
        "fix": {
            "release": "patch"
        },
        "refactor": {
            "release": "none"
        },
        "docs":{
            "release": "none"
        }
    },
    "scopes": {
        "app1": {
            "folderPattern": "app1"
        },
        "app2": {
            "folderPattern": "app2"
        },
        "app3": {
            "folderPattern": "app3"
        }
    }
}

Commit Examples:

Commit Message filles modified Pass
fix(app1): fixed error in the API only files in app1/ ✅ right files modified
fix(app1): fixed error in app2 files in app2/ ❌ because it must ONLY include files in app1/
feat(app2): added new feature for authentication include files in app2/ and the readme/ ❌ because it must ONLY include files in app2/
major(app4): updated endpoints paths include files in app4/ ❌ because app4 is not provided in the scope list
fix: fixed error in app3 only modified app3/ files ❌ missing app3 scope
docs: updated readme only readme/ modified ✅ no scope provided and file does not match any folderPattern

Default Conventional Commits accepted

If you don't provide a settings-file or you don't define any conventional commits inside it, the following prefixes will be used:

  • break: --> updates the MAJOR semver number. Used when a breaking changes are introduced in your code. A commit message example could be "break: deprecate endpoint GET /parties V1".
  • feat: --> updates the MINOR semver number. Used when changes that add new functionality are introduced in your code. A commit message example could be "feat: endpoint GET /parties V2 is now available".
  • fix: --> updates the PATCH semver number. Used when changes that solve bugs are introduced in your code. A commit message example could be "fix: properly manage contact-id parameter in endpoint GET /parties V2".
  • build:, chore:, ci:, docs:, style:, refactor:, perf:, test: --> There are scenarios where you are not affecting any of the previous semver numbers. Those could be: refactoring your code, reducing building time of your code, adding unit tests, improving documentation, ... For these cases, conventional-commits allows for more granular prefixes. A commit message example could be "docs: improve readme with examples".

remarks

  • ⚠️ commits that contain [skip ci] are skipped from the validation.
  • ⚠️ for the actions/checkout@v2 the fetch-depth: 0 parameter is MANDATORY

License Summary

This code is made available under the MIT license. Details here.

ensure-conventional-commits-gh-action's People

Contributors

cangulomascarell avatar lucky-edu avatar ohp-github-svc avatar terraform-ohpensource[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.