Skip to content

Commit cf20b58

Browse files
TPT-4298: Added PR title checking to lint workflow and new clean up release notes workflow (linode#913)
* Added PR title checking to lint and clean up release notes * Fixed CoPilot suggestions * Exclude dependabot PRs from PR title validation * Address CoPilot suggestions * Add exemptions for hotfixes and external contributions * Switch to using amannn/action-semantic-pull-request@v6 for title validation * Add exemption for dependencies label and remove dependabot author check
1 parent 35b2878 commit cf20b58

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,35 @@ on:
1919
jobs:
2020
lint-tidy:
2121
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
pull-requests: read
2225
steps:
26+
# Enforce TPT-1234: prefix on PR titles, with the following exemptions:
27+
# - PRs labeled 'dependencies' (e.g. Dependabot PRs)
28+
# - PRs labeled 'hotfix' (urgent fixes that may not have a ticket)
29+
# - PRs labeled 'community-contribution' (external contributors without TPT tickets)
30+
# - PRs labeled 'ignore-for-release' (release PRs that don't need a ticket prefix)
31+
- name: Validate PR Title
32+
if: github.event_name == 'pull_request'
33+
uses: amannn/action-semantic-pull-request@v6
34+
with:
35+
types: |
36+
TPT-\d+
37+
requireScope: false
38+
# Override the default header pattern to allow hyphens and digits in the type
39+
# (e.g. "TPT-4298: Description"). The default pattern only matches word
40+
# characters (\w) which excludes hyphens.
41+
headerPattern: '^([\w-]+):\s?(.*)$'
42+
headerPatternCorrespondence: type, subject
43+
ignoreLabels: |
44+
dependencies
45+
hotfix
46+
community-contribution
47+
ignore-for-release
48+
env:
49+
GITHUB_TOKEN: ${{ github.token }}
50+
2351
- uses: actions/checkout@v6
2452
- uses: actions/setup-go@v6
2553
with:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Clean Release Notes
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
clean-release-notes:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
13+
steps:
14+
- name: Remove ticket prefixes from release notes
15+
uses: actions/github-script@v7
16+
with:
17+
script: |
18+
const release = context.payload.release;
19+
20+
let body = release.body;
21+
22+
if (!body) {
23+
console.log("Release body empty, nothing to clean.");
24+
return;
25+
}
26+
27+
// Remove ticket prefixes like "TPT-1234: " or "TPT-1234:"
28+
body = body.replace(/TPT-\d+:\s*/g, '');
29+
30+
await github.rest.repos.updateRelease({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
release_id: release.id,
34+
body: body
35+
});
36+
37+
console.log("Release notes cleaned.");

0 commit comments

Comments
 (0)