-
Notifications
You must be signed in to change notification settings - Fork 716
95 lines (81 loc) · 3.26 KB
/
pr-title.yml
File metadata and controls
95 lines (81 loc) · 3.26 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Conventional commits check
on:
# runs on `pull_request_target` events so that commenting on the PR is allowed
pull_request_target:
types: [opened, edited, synchronize, reopened]
jobs:
verify-commitlint:
name: Check PR title conforms to semantic-release
permissions:
contents: read
runs-on: ubuntu-latest
outputs:
lint_output: ${{ steps.lint.outputs.lint_output }}
failed: ${{ steps.lint.outputs.failed }}
steps:
- name: install node
uses: actions/setup-node@v6
with:
node-version: 24
- name: checkout code to pick up commitlint configuration
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: run commitlint
id: lint
run: |
failed=0
if ! lint_output=$(npx --yes commitlint -- --extends "commitlint/config-conventional" --verbose <<< "$COMMIT_MSG" 2>&1); then
failed=1
fi
{
echo "failed=$failed"
echo "lint_output<<EOF"
echo "$lint_output"
echo "EOF"
} | tee -a "$GITHUB_OUTPUT"
exit $failed
env:
COMMIT_MSG: |
${{ github.event.pull_request.title }}
${{ github.event.pull_request.body }}
comment-if-necessary:
permissions:
pull-requests: write
name: Add/update comment describing commitlint failure
runs-on: ubuntu-latest
needs:
- verify-commitlint
steps:
- name: find existing comment
uses: peter-evans/find-comment@v4
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "ACTION NEEDED"
- name: if the PR title and body fail `commitlint`, post or update a comment
if: needs.verify-commitlint.outputs.failed == '1'
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
**ACTION NEEDED**
Ibis follows the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) for release automation.
The PR title and description are used as the merge commit message.
Please update your PR title and description to match the specification.
See https://github.com/ibis-project/ibis/blob/main/.releaserc.js
for the list of acceptable prefixes, eg "feat:", "fix:", "chore:", etc.
The commitlint output is:
```
${{ needs.verify-commitlint.outputs.lint_output }}
```
- name: If commitlint now passes, and comment exists, update it
if: needs.verify-commitlint.outputs.failed == '0' && steps.find-comment.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: The PR title and description conform to the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).