diff --git a/.commit-check.yml b/.commit-check.yml new file mode 100644 index 000000000..05818cb2a --- /dev/null +++ b/.commit-check.yml @@ -0,0 +1,30 @@ +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 ,.\'-]+$|.*(\[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: master # 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/artifact.yml b/.github/workflows/artifact.yml index 6f6e4d17c..3662e76f9 100644 --- a/.github/workflows/artifact.yml +++ b/.github/workflows/artifact.yml @@ -21,6 +21,7 @@ on: - 'qodana.yaml' - 'SECURITY.md' - '.imgbotconfig' + - '.commit-check.yml' workflow_dispatch: concurrency: # On master/release, we don't want any jobs cancelled so the sha is used to name the group diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml new file mode 100644 index 000000000..efe9bf25a --- /dev/null +++ b/.github/workflows/commit-check.yml @@ -0,0 +1,29 @@ +name: Commit Check + +on: + pull_request: + branches: 'master' + +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 + fetch-depth: 0 # required for merge-base check + - uses: commit-check/commit-check-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.CHANGELOG }} # use GITHUB_TOKEN because of use pr-comments + with: + message: false + branch: false + author-name: true + author-email: true + commit-signoff: true + merge-base: false + job-summary: true + pr-comments: true