Skip to content

Commit 68655f6

Browse files
committed
chore: add CHANGELOG.md check workflow on PRs
Fails a PR when CHANGELOG.md is not updated unless the description states "No customer facing changes" to justify skipping the changelog. Also documents the opt-out phrase in the PR template.
1 parent 5145abc commit 68655f6

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

.github/pull_request_template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
## 🧪 How to test?
1010
> How to test the changes added?
1111
12+
## 🧾 Changelog
13+
> Add an entry to `CHANGELOG.md`. If this PR has no customer facing changes, write "No customer facing changes" here to skip the changelog check.
14+
1215
## 📹 Loom recording if applicable
1316
> If it helps the reviewer, add a short Loom going over the changes or showcasing the change in behavior.
1417
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Changelog Check
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize, reopened]
5+
6+
permissions:
7+
contents: read
8+
pull-requests: read
9+
10+
jobs:
11+
changelog:
12+
name: Verify CHANGELOG update
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check CHANGELOG.md update or opt-out
16+
uses: actions/github-script@v7
17+
with:
18+
script: |
19+
const optOut = 'No customer facing changes';
20+
const body = context.payload.pull_request.body || '';
21+
22+
if (body.toLowerCase().includes(optOut.toLowerCase())) {
23+
core.info(`PR description contains "${optOut}", skipping CHANGELOG.md check.`);
24+
return;
25+
}
26+
27+
const files = await github.paginate(github.rest.pulls.listFiles, {
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
pull_number: context.payload.pull_request.number,
31+
per_page: 100,
32+
});
33+
34+
const changed = files.some((f) => f.filename === 'CHANGELOG.md');
35+
if (changed) {
36+
core.info('CHANGELOG.md was updated.');
37+
return;
38+
}
39+
40+
core.setFailed(
41+
'CHANGELOG.md was not updated. Add a CHANGELOG.md entry, or if this PR has no customer facing changes, add "No customer facing changes" to the PR description to justify skipping the changelog.'
42+
);

0 commit comments

Comments
 (0)