diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4f08a45..37cffb1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @shenxianpeng +* @commit-check/developers diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index dc398fd..b22e048 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -12,7 +12,7 @@ jobs: contents: read pull-requests: write steps: - - uses: actions/checkout@v4 + - 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 @@ -26,5 +26,6 @@ jobs: 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/main.yaml b/.github/workflows/release.yaml similarity index 94% rename from .github/workflows/main.yaml rename to .github/workflows/release.yaml index 913593d..a9edb15 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/release.yaml @@ -1,9 +1,9 @@ -name: Main +name: Release on: release: branches: [main] - types: [published] + types: [released] workflow_dispatch: inputs: tag: @@ -19,7 +19,7 @@ jobs: re-tag: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 ref: ${{ inputs.ref }} diff --git a/.github/workflows/used-by.yml b/.github/workflows/used-by.yml index 0625b49..fae6e88 100644 --- a/.github/workflows/used-by.yml +++ b/.github/workflows/used-by.yml @@ -14,7 +14,7 @@ jobs: used-by: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: shenxianpeng/used-by@v0.1.4 with: repo: '${{ github.repository }}' diff --git a/README.md b/README.md index 864c2a9..06fcc86 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ # Commit-Check GitHub Action -[![Main](https://github.com/commit-check/commit-check-action/actions/workflows/main.yaml/badge.svg)](https://github.com/commit-check/commit-check-action/actions/workflows/main.yaml) [![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) ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/commit-check/commit-check-action) -[![Used by](https://img.shields.io/static/v1?label=Used%20by&message=64&color=informational&logo=slickpic)](https://github.com/commit-check/commit-check-action/network/dependents) +[![Used by](https://img.shields.io/static/v1?label=Used%20by&message=68&color=informational&logo=slickpic)](https://github.com/commit-check/commit-check-action/network/dependents) [![GitHub marketplace](https://img.shields.io/badge/Marketplace-commit--check--action-blue)](https://github.com/marketplace/actions/commit-check-action) [![slsa-badge](https://slsa.dev/images/gh-badge-level3.svg)](https://github.com/commit-check/commit-check-action/blob/a2873ca0482dd505c93fb51861c953e82fd0a186/action.yml#L59-L69) -A Github Action for checking commit message formatting, branch naming, committer name, email, commit signoff and more. +A GitHub Action for checking commit message formatting, branch naming, committer name, email, commit signoff, and more. ## Table of Contents @@ -33,7 +32,7 @@ on: jobs: commit-check: runs-on: ubuntu-latest - permissions: # use permissions because of use pr-comments + permissions: # use permissions because use of pr-comments contents: read pull-requests: write steps: @@ -43,7 +42,7 @@ jobs: fetch-depth: 0 # required for merge-base check - uses: commit-check/commit-check-action@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # use GITHUB_TOKEN because of use pr-comments + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # use GITHUB_TOKEN because use of pr-comments with: message: true branch: true @@ -51,6 +50,7 @@ jobs: author-email: true commit-signoff: true merge-base: false + imperative: false job-summary: true pr-comments: ${{ github.event_name == 'pull_request' }} ``` @@ -70,6 +70,8 @@ jobs: Extrawest Chainlift Chainlift   + Mila + Mila   and many more.

@@ -78,13 +80,13 @@ jobs: ### `message` - **Description**: check commit message formatting convention. - - By default the rule follows [conventional commits](https://www.conventionalcommits.org/). + - By default, the rule follows [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/). + - By default, the rule follows [conventional branch](https://conventional-branch.github.io/). - Default: `true` ### `author-name` @@ -104,17 +106,22 @@ jobs: ### `merge-base` -- **Description**: check current branch is rebased onto target branch. +- **Description**: check current branch is rebased onto the target branch. - Default: `false` > [!IMPORTANT] -> `merge-base` is an experimental feature. by default it's disable. +> `merge-base` is an experimental feature. By default, it's disabled. > -> To use this feature, you need fetch all history for all branches by setting `fetch-depth: 0` in `actions/checkout`. +> 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` -- **Description**: run checks without failing. exit code is 0 otherwise is 1. +- **Description**: run checks without failing. exit code is 0; otherwise is 1. - Default: `false` ### `job-summary` @@ -128,11 +135,11 @@ jobs: - Default: `false` > [!IMPORTANT] -> `pr-comments` is an experimental feature. by default it's disable. To use it you need to set `GITHUB_TOKEN` in the GitHub Action. +> `pr-comments` is an experimental feature. By default, it's disabled. To use it, you need to set `GITHUB_TOKEN` in the GitHub Action. > > 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/blob/main/.commit-check.yml). If you want to customize, just add your `.commit-check.yml` config file under your repository root directory. ## GitHub Action Job Summary @@ -183,4 +190,4 @@ Versioning follows [Semantic Versioning](https://semver.org/). ## Have questions or feedback? -To provide feedback (requesting a feature or reporting a bug) please post to [issues](https://github.com/commit-check/commit-check/issues). +To provide feedback (requesting a feature or reporting a bug), please post to [issues](https://github.com/commit-check/commit-check/issues). diff --git a/action.yml b/action.yml index cdd75ea..eb12512 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,10 @@ inputs: 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 required: false @@ -66,7 +70,7 @@ runs: fi # Install artifact - python3 -m pip install commit_check-*.whl PyGithub-*.whl + python3 -m pip install commit_check-*.whl pygithub-*.whl python3 "$GITHUB_ACTION_PATH/main.py" env: @@ -76,6 +80,7 @@ runs: 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/main.py b/main.py index 87434ec..ef9c920 100755 --- a/main.py +++ b/main.py @@ -17,6 +17,7 @@ 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") @@ -34,6 +35,7 @@ def log_env_vars(): 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,12 +50,21 @@ def run_commit_check() -> int: "--author-email", "--commit-signoff", "--merge-base", + "--imperative", ] args = [ arg for arg, value in zip( args, - [MESSAGE, BRANCH, AUTHOR_NAME, AUTHOR_EMAIL, COMMIT_SIGNOFF, MERGE_BASE], + [ + MESSAGE, + BRANCH, + AUTHOR_NAME, + AUTHOR_EMAIL, + COMMIT_SIGNOFF, + MERGE_BASE, + IMPERATIVE, + ], ) if value == "true" ] diff --git a/requirements.txt b/requirements.txt index e16e5b7..e5ff28b 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.9.6 +commit-check==0.10.1 # Interact with the GitHub API. -PyGithub==2.6.1 +PyGithub==2.7.0