forked from trycompai/crm
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (103 loc) · 4.2 KB
/
Copy pathpr-title.yml
File metadata and controls
120 lines (103 loc) · 4.2 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: PR title
on:
pull_request:
types: [opened, edited, reopened, ready_for_review, synchronize]
branches: [main]
concurrency:
group: pr-title-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
conventional:
name: conventional commit
if: >-
github.event.pull_request.draft == false &&
!startsWith(github.event.pull_request.head.ref, 'release-please--')
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Write the title from the diff
id: autotitle
env:
GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN || secrets.GITHUB_TOKEN }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
ACTION: ${{ github.event.action }}
TITLE: ${{ github.event.pull_request.title }}
BODY: ${{ github.event.pull_request.body }}
NUMBER: ${{ github.event.pull_request.number }}
BRANCH: ${{ github.event.pull_request.head.ref }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
body=$(printf '%s' "$BODY" | tr -d '\r')
written=$(printf '%s\n' "$body" | sed -n 's/^<!-- pr-title: \(.*\) -->$/\1/p' | head -1)
if ! .github/scripts/pr-title.sh check "$TITLE"; then
reason="it is not a release note"
elif [ "$ACTION" != "edited" ] && [ -n "$written" ] && [ "$written" = "$TITLE" ]; then
reason="the diff has moved and nobody has retitled it"
else
echo "\`$TITLE\` is yours — leaving it alone." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
title=$(.github/scripts/pr-title.sh generate "$BASE_SHA" "$HEAD_SHA" "$BRANCH")
if [ "$title" = "$TITLE" ]; then
echo "\`$TITLE\` still describes the diff." >> "$GITHUB_STEP_SUMMARY"
echo "written=true" >> "$GITHUB_OUTPUT"
exit 0
fi
body=$(printf '%s\n\n<!-- pr-title: %s -->\n' \
"$(printf '%s\n' "$body" | grep -v '^<!-- pr-title: ' || true)" "$title")
gh pr edit "$NUMBER" --title "$title" --body "$body"
echo "written=true" >> "$GITHUB_OUTPUT"
echo "Retitled #$NUMBER to \`$title\`, because $reason." >> "$GITHUB_STEP_SUMMARY"
- uses: amannn/action-semantic-pull-request@v6
id: lint
if: steps.autotitle.outputs.written != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
perf
refactor
docs
revert
deps
chore
test
ci
build
style
requireScope: false
subjectPattern: ^(?![A-Z][a-z]).+[^.]$
subjectPatternError: >-
The subject "{subject}" of "{title}" reads like a sentence, not a
changelog line. Start it lowercase and in the imperative, and drop
the trailing full stop — "add bulk archive to the deals table",
not "Added bulk archive."
- uses: marocchino/sticky-pull-request-comment@v2
if: always()
continue-on-error: true
with:
header: pr-title
delete: ${{ steps.lint.outputs.error_message == null }}
message: |
**This pull request's title is not a Conventional Commit.**
It is squashed onto `main` as-is, so the title is the commit subject and the line that shows up in the changelog and the release notes.
```
${{ steps.lint.outputs.error_message }}
```
| Title | Bump | Changelog heading |
| --- | --- | --- |
| `feat(app): add bulk archive to the deals table` | minor | Features |
| `fix(api): stop double-counting installs` | patch | Fixes |
| `feat(db)!: drop the legacy contacts table` | major | Features, flagged breaking |
| `chore(deps): bump turbo to 2.11` | none | hidden |
Edit the title and this check re-runs on its own.