Skip to content

Commit 16a798f

Browse files
authored
Merge branch 'main' into verify-artifact-attestations
2 parents 2a64446 + f87ca4d commit 16a798f

File tree

9 files changed

+240
-60
lines changed

9 files changed

+240
-60
lines changed

.commit-check.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ checks:
77
[optional body]\n
88
[optional footer(s)]\n\n
99
More details please refer to https://www.conventionalcommits.org"
10-
suggest: git commit --amend --no-verify
10+
suggest: please check your commit message whether matches above regex
1111

1212
- check: branch
13-
regex: ^(bugfix|feature|release|hotfix|task|dependabot)\/.+|(master)|(main)|(HEAD)|(PR-.+)
14-
error: "Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/"
15-
suggest: git checkout -b type/branch_name
13+
regex: ^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+)
14+
error: "Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/"
15+
suggest: run command `git checkout -b type/branch_name`
1616

1717
- check: author_name
1818
regex: ^[A-Za-z ,.\'-]+$|.*(\[bot])
1919
error: The committer name seems invalid
20-
suggest: git config user.name "Peter Shen"
20+
suggest: run command `git config user.name "Your Name"`
2121

2222
- check: author_email
23-
regex: ^\S+@\S+\.\S+$
23+
regex: ^.+@.+$
2424
error: The committer email seems invalid
25-
suggest: git config user.email petershen@example.com
25+
suggest: run command `git config user.email yourname@example.com`

.github/workflows/commit-check.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ on:
88
jobs:
99
commit-check:
1010
runs-on: ubuntu-latest
11+
permissions: # use permissions because of use pr-comments
12+
contents: read
13+
pull-requests: write
1114
steps:
1215
- uses: actions/checkout@v4
13-
- uses: ./ # self test
16+
with:
17+
ref: ${{ github.event.pull_request.head.sha }} # checkout PR HEAD commit
18+
- uses: ./ # self test
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # use GITHUB_TOKEN because of use pr-comments
1421
with:
1522
message: true
1623
branch: true
1724
author-name: true
1825
author-email: true
1926
commit-signoff: true
2027
job-summary: true
28+
pr-comments: ${{ github.event_name == 'pull_request' }}

.github/workflows/used-by.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
18-
- uses: shenxianpeng/used-by@v0.1.2
18+
- uses: shenxianpeng/used-by@v0.1.4
1919
with:
2020
repo: '${{ github.repository }}'
2121
update-badge: 'true'
2222

2323
- name: Create Pull Request
24-
uses: peter-evans/create-pull-request@v6
24+
uses: peter-evans/create-pull-request@v7
2525
with:
2626
add-paths: "README.md" # the file path to commit
2727
commit-message: "chore: update used-by badge by github-actions[bot]"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
venv/
2+
.venv/

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# https://pre-commit.com/
2+
ci:
3+
autofix_commit_msg: 'ci: auto fixes from pre-commit.com hooks'
4+
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
5+
6+
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v5.0.0
9+
hooks:
10+
- id: check-yaml
11+
- id: check-toml
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+
- id: name-tests-test
15+
- id: requirements-txt-fixer
16+
- repo: https://github.com/psf/black-pre-commit-mirror
17+
rev: 24.10.0
18+
hooks:
19+
- id: black
20+
# FIXME: main.py:109: error: Item "None" of "str | None" has no attribute "split" [union-attr]
21+
# - repo: https://github.com/pre-commit/mirrors-mypy
22+
# rev: v1.12.0
23+
# hooks:
24+
# - id: mypy
25+
- repo: https://github.com/codespell-project/codespell
26+
rev: v2.3.0
27+
hooks:
28+
- id: codespell

README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![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)
44
[![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)
55
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/commit-check/commit-check-action)
6-
[![Used by](https://img.shields.io/static/v1?label=Used%20by&message=18&color=informational&logo=slickpic)](https://github.com/commit-check/commit-check-action/network/dependents)<!-- used by badge -->
6+
[![Used by](https://img.shields.io/static/v1?label=Used%20by&message=37&color=informational&logo=slickpic)](https://github.com/commit-check/commit-check-action/network/dependents)<!-- used by badge -->
77
[![GitHub marketplace](https://img.shields.io/badge/Marketplace-commit--check--action-blue)](https://github.com/marketplace/actions/commit-check-action)
88

99
A Github Action for checking commit message formatting, branch naming, committer name, email, commit signoff and more.
@@ -23,17 +23,24 @@ on:
2323
jobs:
2424
commit-check:
2525
runs-on: ubuntu-latest
26+
permissions: # use permissions because of use pr-comments
27+
contents: read
28+
pull-requests: write
2629
steps:
2730
- uses: actions/checkout@v4
31+
with:
32+
ref: ${{ github.event.pull_request.head.sha }} # checkout PR HEAD commit
2833
- uses: commit-check/commit-check-action@v1
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # use GITHUB_TOKEN because of use pr-comments
2936
with:
3037
message: true
3138
branch: true
3239
author-name: true
3340
author-email: true
3441
commit-signoff: true
35-
dry-run: true
3642
job-summary: true
43+
pr-comments: ${{ github.event_name == 'pull_request' }}
3744
```
3845
3946
## Optional Inputs
@@ -47,7 +54,7 @@ jobs:
4754
### `branch`
4855

4956
- **Description**: check git branch naming convention.
50-
- By default follow bitbucket [branching model](https://support.atlassian.com/bitbucket-cloud/docs/configure-a-projects-branching-model/).
57+
- By default follow bitbucket [conventional branch](https://conventional-branch.github.io/).
5158
- Default: 'true'
5259

5360
### `author-name`
@@ -72,22 +79,41 @@ jobs:
7279

7380
### `job-summary`
7481

75-
- **Description**: display job summary to a workflow run
82+
- **Description**: display job summary to the workflow run
7683
- Default: 'true'
7784

85+
### `pr-comments`
86+
87+
- **Description**: post results to the pull request comments
88+
- Default: 'true'
89+
90+
> [!IMPORTANT]
91+
> This is a experimental feature
92+
> use it you need to set `GITHUB_TOKEN` in the GitHub Action.
93+
7894
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.
7995

8096
## GitHub Action job summary
8197

82-
By default, commit-check-action results are shown on the job summary page of the workflow.
98+
By default, commit-check-action results are shown on the job summary page of the workflow.
8399

84100
### Success job summary
85101

86-
![Success job summary](https://github.com/commit-check/.github/blob/main/screenshot/success-summary.png)
102+
![Success job summary](https://github.com/commit-check/.github/blob/main/screenshot/success-job-summary.png)
87103

88104
### Failure job summary
89105

90-
![Failure job summary](https://github.com/commit-check/.github/blob/main/screenshot/failure-summary.png)
106+
![Failure job summary](https://github.com/commit-check/.github/blob/main/screenshot/failure-job-summary.png)
107+
108+
## GitHub Pull Request comments
109+
110+
### Success pull request comment
111+
112+
![Success pull request comment](https://github.com/commit-check/.github/blob/main/screenshot/success-pr-comments.png)
113+
114+
### Failure pull request comment
115+
116+
![Failure pull request comment](https://github.com/commit-check/.github/blob/main/screenshot/failure-pr-comments.png)
91117

92118
## Badging your repository
93119

action.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ inputs:
3030
required: false
3131
default: false
3232
job-summary:
33-
description: add a job summary
33+
description: display job summary to the workflow run
34+
required: false
35+
default: true
36+
pr-comments:
37+
description: post results to the pull request comments
3438
required: false
3539
default: true
3640
runs:
3741
using: "composite"
3842
steps:
39-
- name: Install action dependencies
43+
- name: Install dependencies and run commit-check
4044
shell: bash
4145
run: |
4246
if [[ "$RUNNER_OS" == "Linux" ]]; then
@@ -51,11 +55,9 @@ runs:
5155
5256
# Install artifact
5357
python3 -m pip install commit_check-*.whl
54-
env:
55-
GH_TOKEN: ${{ github.token }}
56-
- name: Run commit-check
57-
shell: bash
58-
run: python3 ${{ github.action_path }}/main.py
58+
python3 -m venv venv
59+
source venv/bin/activate
60+
python3 "$GITHUB_ACTION_PATH/main.py"
5961
env:
6062
MESSAGE: ${{ inputs.message }}
6163
BRANCH: ${{ inputs.branch }}
@@ -64,3 +66,4 @@ runs:
6466
COMMIT_SIGNOFF: ${{ inputs.commit-signoff }}
6567
DRY_RUN: ${{ inputs.dry-run }}
6668
JOB_SUMMARY: ${{ inputs.job-summary }}
69+
PR_COMMENTS: ${{ inputs.pr-comments }}

0 commit comments

Comments
 (0)