-
Notifications
You must be signed in to change notification settings - Fork 35
59 lines (49 loc) · 2.33 KB
/
Copy pathpr-title.yml
File metadata and controls
59 lines (49 loc) · 2.33 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
name: PR title
# The PR title becomes the squash-merge commit subject, so it must pass the
# same commitlint rules as a commit message. Runs on pull_request_target so it
# can post a sticky comment on fork PRs; it never checks out PR-head code and
# reads the title only through an env var (never interpolated into a shell).
on:
pull_request_target:
types: [opened, edited, reopened, ready_for_review]
permissions:
contents: read
pull-requests: write
concurrency:
group: pr-title-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
validate:
name: Validate title
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ !github.event.pull_request.draft }}
steps:
# Default ref is the base branch (trusted), not PR head.
# commitlint.config.mjs is the single source of truth for types + scopes.
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: pnpm/action-setup@ac6db6d3c1f721f886538a378a2d73e85697340a # v6.0.8
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version-file: .nvmrc
cache: pnpm
- run: pnpm install --frozen-lockfile
- id: commitlint
continue-on-error: true
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: printf '%s' "$PR_TITLE" | pnpm exec commitlint
- uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
if: steps.commitlint.outcome == 'failure'
with:
header: pr-title-lint-error
message: |
## ❌ PR title is not a valid Conventional Commit
Expected `<type>(<scope>)?: <subject>`. The commitlint output in the failed check names the rule that broke. The allowed `type` and `scope` sets are defined in [`commitlint.config.mjs`](https://github.com/ls1intum/Apollon/blob/main/commitlint.config.mjs) (the single source of truth); see also [`CONTRIBUTING.md`](https://github.com/ls1intum/Apollon/blob/main/CONTRIBUTING.md).
- uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
if: steps.commitlint.outcome == 'success'
with:
header: pr-title-lint-error
delete: true
- if: steps.commitlint.outcome == 'failure'
run: exit 1