-
Notifications
You must be signed in to change notification settings - Fork 508
47 lines (39 loc) · 1.68 KB
/
pr-commit-signatures.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: "Commit signatures"
on:
pull_request:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Fetch commits
run: gh api "${{ github.event.pull_request._links.commits.href }}" | tee commits.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Filter unverified commits
run: jq '[.[].commit | select(.verification.verified == false)]' < commits.json | tee unverified-commits.json
- name: List unverified commits
run: jq '.[] | [{message, tree, author, committer, verification}]' < unverified-commits.json
- name: Result
run: |
COUNT="$(jq '. | length' < unverified-commits.json)"
if [[ "$COUNT" == "0" ]];
then
echo "✅ All commits are verified."
exit 0
fi
echo "❌ PR contains $COUNT unverified commit(s)!"
echo ""
echo "Please note that we require that all commits are signed."
echo "Please see the documentation about signed commits and how to sign yours on GitHub:"
echo "- https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification"
echo "- https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits"
echo ''
echo 'Once you have set up commit signatures, you can sign your existing commits:'
echo ''
echo ' git rebase main --exec "git commit --amend --gpg-sign --no-edit"'
echo ''
echo 'Then you will need to force-push your branch once:'
echo ''
echo ' git push --force'
echo ''
exit 1