Skip to content

Commit ba02a3e

Browse files
committed
feat: the Pull Request action now verifies signed commits
1 parent 25c486b commit ba02a3e

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

.github/workflows/pull-request.yaml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,53 @@ jobs:
2222
name: Check PR title and commit messages
2323
runs-on: ubuntu-latest
2424
steps:
25+
2526
- name: Check out repository
2627
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
2728
with:
2829
fetch-depth: 0
30+
2931
- name: Set up Python
3032
uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 # v4.2.0
3133
with:
3234
python-version: '3.10'
3335

3436
# Install Commitizen without using the package's Makefile: that's much faster than
35-
# creating a venv and installing heaps of dependencies that aren't required for
36-
# this job. Then run Commitizen to check the title of the PR which triggered this
37-
# workflow, and check all commit messages of the PR's branch. If any of the checks
38-
# fails then this job fails.
37+
# creating a venv and installing heaps of dependencies that aren't required for this job.
3938
- name: Set up Commitizen
4039
run: |
4140
pip install --upgrade pip wheel
4241
pip install 'commitizen ==2.32.1'
42+
4343
- name: Check PR title
4444
run: echo "$PR_TITLE" | cz check
4545
env:
4646
PR_TITLE: ${{ github.event.pull_request.title }}
47-
- name: Check PR commit messages
47+
48+
- name: Add and fetch remote branch
4849
run: |
4950
git remote add other $PR_HEAD_REPO_CLONE_URL
5051
git fetch other
51-
cz check --rev-range origin/$PR_BASE_REF..other/$PR_HEAD_REF
52+
env:
53+
PR_HEAD_REPO_CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url }}
54+
55+
- name: Check PR commit messages
56+
run: cz check --rev-range origin/$PR_BASE_REF..other/$PR_HEAD_REF
5257
env:
5358
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
5459
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
55-
PR_HEAD_REPO_CLONE_URL: ${{ github.event.pull_request.head.repo.clone_url }}
60+
61+
- name: Check PR commit signatures
62+
shell: bash
63+
run: |
64+
for sha in `git log --format=format:%H $PR_BASE_REF..$PR_HEAD_REF`
65+
do
66+
echo "Checking signature for commit $sha"
67+
git verify-commit $sha
68+
done
69+
env:
70+
PR_BASE_REF: ${{ github.event.pull_request.base.sha }}
71+
PR_HEAD_REF: ${{ github.event.pull_request.head.sha }}
5672

5773
build:
5874
needs: conventional-commits

0 commit comments

Comments
 (0)