diff --git a/.commit-check.yml b/.commit-check.yml deleted file mode 100644 index f1f725f..0000000 --- a/.commit-check.yml +++ /dev/null @@ -1,30 +0,0 @@ -checks: - - - check: message - regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)|(Merge).*|(fixup!.*)' - error: "The commit message should be structured as follows:\n\n - [optional scope]: \n - [optional body]\n - [optional footer(s)]\n\n - More details please refer to https://www.conventionalcommits.org" - suggest: please check your commit message whether matches above regex - - - check: branch - regex: ^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+) - error: "Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/" - suggest: run command `git checkout -b type/branch_name` - - - check: author_name - regex: ^[A-Za-zÀ-ÖØ-öø-ÿ\u0100-\u017F\u0180-\u024F ,.\'-]+$|.*(\[bot]) - error: The committer name seems invalid - suggest: run command `git config user.name "Your Name"` - - - check: author_email - regex: ^.+@.+$ - error: The committer email seems invalid - suggest: run command `git config user.email yourname@example.com` - - - check: merge_base - regex: main # it can be master, develop, devel etc based on your project. - error: Current branch is not rebased onto target branch - suggest: please ensure your branch is rebased with the target branch diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index b22e048..01ee50a 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -14,18 +14,15 @@ jobs: steps: - uses: actions/checkout@v5 with: - ref: ${{ github.event.pull_request.head.sha }} # checkout PR HEAD commit - fetch-depth: 0 # fetch all history for all branches and tags + ref: ${{ github.event.pull_request.head.ref }} # Checkout PR branch + fetch-depth: 0 # Required for merge-base checks - uses: ./ # self test env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # use GITHUB_TOKEN because of use pr-comments + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed for PR comments with: message: true branch: true author-name: true author-email: true - commit-signoff: true - merge-base: true - imperative: true job-summary: true pr-comments: ${{ github.event_name == 'pull_request' }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 10087ef..54b1e22 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,7 +10,7 @@ on: inputs: tag: description: 'which tag to update to' - default: 'v1' + default: 'v2' required: true ref: description: 'which branch to update the tag on' @@ -36,10 +36,10 @@ jobs: git push --delete origin ${{ inputs.tag }} || true git tag -a ${{ inputs.tag }} -m 'Retag ${{ inputs.tag }}' git push origin ${{ inputs.tag }} - - name: Update tag to v1 + - name: Update tag to v2 if: github.event.inputs.tag == '' run: | - git tag --delete v1 || true - git push --delete origin v1 || true - git tag -a v1 -m 'Retag v1' - git push origin v1 + git tag --delete v2 || true + git push --delete origin v2 || true + git tag -a v2 -m 'Retag v2' + git push origin v2 diff --git a/README.md b/README.md index 1feaa9c..f3d1c89 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,18 @@ A GitHub Action for checking commit message formatting, branch naming, committer name, email, commit signoff, and more. +## What's New in v2 + +> [!IMPORTANT] +> This v2 release introduces several 🚨**breaking changes**. Please review the [Breaking Changes](#breaking-changes) section carefully before upgrading. + +### Breaking Changes + +- Removed support for `commit-signoff`, `merge-base`, and `imperative` inputs — now configured via `commit-check.toml` or `cchk.toml`. +- Deprecated `.commit-check.yml` in favor of `commit-check.toml` or `cchk.toml`. +- Changed default values of `author-name` and `author-email` inputs to `false` to align with the default behavior in commit-check. +- Upgraded core dependency [`commit-check`](https://github.com/commit-check/commit-check) to [**v2.0.0**](https://github.com/commit-check/commit-check/releases/tag/v2.0.0). + ## Table of Contents * [Usage](#usage) @@ -38,19 +50,16 @@ jobs: steps: - uses: actions/checkout@v5 with: - ref: ${{ github.event.pull_request.head.sha }} # checkout PR HEAD commit - fetch-depth: 0 # required for merge-base check - - uses: commit-check/commit-check-action@v1 + ref: ${{ github.event.pull_request.head.ref }} # Checkout PR branch + fetch-depth: 0 # Required for merge-base checks + - uses: commit-check/commit-check-action@v2 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # use GITHUB_TOKEN because use of pr-comments + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed for PR comments with: message: true branch: true - author-name: true - author-email: true - commit-signoff: true - merge-base: false - imperative: false + author-name: false + author-email: false job-summary: true pr-comments: ${{ github.event_name == 'pull_request' }} ``` @@ -81,44 +90,22 @@ jobs: ### `message` -- **Description**: check commit message formatting convention. - - By default, the rule follows [Conventional Commits](https://www.conventionalcommits.org/). +- **Description**: check git commit message following [Conventional Commits](https://www.conventionalcommits.org/). - Default: `true` ### `branch` -- **Description**: check git branch naming convention. - - By default, the rule follows [Conventional Branch](https://conventional-branch.github.io/). +- **Description**: check git branch name following [Conventional Branch](https://conventional-branch.github.io/). - Default: `true` ### `author-name` - **Description**: check committer author name. -- Default: `true` +- Default: `false` ### `author-email` - **Description**: check committer author email. -- Default: `true` - -### `commit-signoff` - -- **Description**: check committer commit signature. -- Default: `true` - -### `merge-base` - -- **Description**: check current branch is rebased onto the target branch. -- Default: `false` - -> [!IMPORTANT] -> `merge-base` is an experimental feature. By default, it's disabled. -> -> To use this feature, you need to fetch all history for all branches by setting `fetch-depth: 0` in `actions/checkout`. - -### `imperative` - -- **Description**: check commit message is imperative mood. - Default: `false` ### `dry-run` @@ -141,7 +128,7 @@ jobs: > > This feature currently doesn’t work with forked repositories. For more details, refer to issue [#77](https://github.com/commit-check/commit-check-action/issues/77). -Note: the default rule of above inputs is following [this configuration](https://github.com/commit-check/commit-check/blob/main/.commit-check.yml). If you want to customize, just add your `.commit-check.yml` config file under your repository root directory. +Note: the default rule of above inputs is following [this configuration](https://github.com/commit-check/commit-check-action/blob/main/commit-check.toml). If you want to customize, just add your [`commit-check.toml`](https://commit-check.github.io/commit-check/configuration.html) config file under your repository root directory. ## GitHub Action Job Summary diff --git a/action.yml b/action.yml index eb12512..68df492 100644 --- a/action.yml +++ b/action.yml @@ -6,32 +6,20 @@ branding: color: "blue" inputs: message: - description: check commit message formatting convention + description: check git commit message following conventional commits required: false default: true branch: - description: check git branch naming convention + description: check git branch name following conventional branch required: false default: true author-name: description: check committer author name required: false - default: true + default: false author-email: description: check committer author email required: false - default: true - commit-signoff: - description: check committer commit signature - required: false - default: true - merge-base: - description: check current branch is rebased onto target branch - required: false - default: false - imperative: - description: check commit message is in imperative mood - required: false default: false dry-run: description: run checks without failing @@ -78,9 +66,6 @@ runs: BRANCH: ${{ inputs.branch }} AUTHOR_NAME: ${{ inputs.author-name }} AUTHOR_EMAIL: ${{ inputs.author-email }} - COMMIT_SIGNOFF: ${{ inputs.commit-signoff }} - MERGE_BASE: ${{ inputs.merge-base }} - IMPERATIVE: ${{ inputs.imperative }} DRY_RUN: ${{ inputs.dry-run }} JOB_SUMMARY: ${{ inputs.job-summary }} PR_COMMENTS: ${{ inputs.pr-comments }} diff --git a/commit-check.toml b/commit-check.toml new file mode 100644 index 0000000..5eec90c --- /dev/null +++ b/commit-check.toml @@ -0,0 +1,23 @@ +[commit] +# https://www.conventionalcommits.org +conventional_commits = true +subject_capitalized = false +subject_imperative = true +subject_max_length = 80 +subject_min_length = 5 +allow_commit_types = ["feat", "fix", "docs", "style", "refactor", "test", "chore", "ci"] +allow_merge_commits = true +allow_revert_commits = true +allow_empty_commits = false +allow_fixup_commits = true +allow_wip_commits = false +require_body = false +require_signed_off_by = false +ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]"] + +[branch] +# https://conventional-branch.github.io/ +conventional_branch = true +allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix"] +require_rebase_target = "origin/main" +ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]"] diff --git a/main.py b/main.py index 8a57c64..2ec7ea5 100755 --- a/main.py +++ b/main.py @@ -15,9 +15,6 @@ BRANCH = os.getenv("BRANCH", "false") AUTHOR_NAME = os.getenv("AUTHOR_NAME", "false") AUTHOR_EMAIL = os.getenv("AUTHOR_EMAIL", "false") -COMMIT_SIGNOFF = os.getenv("COMMIT_SIGNOFF", "false") -MERGE_BASE = os.getenv("MERGE_BASE", "false") -IMPERATIVE = os.getenv("IMPERATIVE", "true") DRY_RUN = os.getenv("DRY_RUN", "false") JOB_SUMMARY = os.getenv("JOB_SUMMARY", "false") PR_COMMENTS = os.getenv("PR_COMMENTS", "false") @@ -33,9 +30,6 @@ def log_env_vars(): print(f"BRANCH = {BRANCH}") print(f"AUTHOR_NAME = {AUTHOR_NAME}") print(f"AUTHOR_EMAIL = {AUTHOR_EMAIL}") - print(f"COMMIT_SIGNOFF = {COMMIT_SIGNOFF}") - print(f"MERGE_BASE = {MERGE_BASE}") - print(f"IMPERATIVE = {IMPERATIVE}") print(f"DRY_RUN = {DRY_RUN}") print(f"JOB_SUMMARY = {JOB_SUMMARY}") print(f"PR_COMMENTS = {PR_COMMENTS}\n") @@ -48,9 +42,6 @@ def run_commit_check() -> int: "--branch", "--author-name", "--author-email", - "--commit-signoff", - "--merge-base", - "--imperative", ] args = [ arg @@ -61,9 +52,6 @@ def run_commit_check() -> int: BRANCH, AUTHOR_NAME, AUTHOR_EMAIL, - COMMIT_SIGNOFF, - MERGE_BASE, - IMPERATIVE, ], ) if value == "true" diff --git a/requirements.txt b/requirements.txt index 133fa28..27bbca8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # Install commit-check CLI # For details please see: https://github.com/commit-check/commit-check -commit-check==0.10.2 +commit-check==2.0.0 # Interact with the GitHub API. PyGithub==2.8.1