Skip to content

Commit 27822a1

Browse files
committed
CI: Add check for changelog entry
1 parent 0a00664 commit 27822a1

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Changelog Entry
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, labeled, unlabeled]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
check:
13+
name: Check changelog entry
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Verify changelog entry or "no changelog" label
17+
env:
18+
GH_TOKEN: ${{ github.token }}
19+
REPO: ${{ github.repository }}
20+
PR_NUMBER: ${{ github.event.pull_request.number }}
21+
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
22+
run: |
23+
set -euo pipefail
24+
if echo "$LABELS" | jq -e 'index("no changelog")' > /dev/null; then
25+
echo "PR is labeled 'no changelog' - skipping check."
26+
exit 0
27+
fi
28+
expected="^changelog\\.d/${PR_NUMBER}\\.[^/]+\\.md$"
29+
matching=$(gh api "repos/$REPO/pulls/$PR_NUMBER/files" --paginate \
30+
| jq -r '.[] | select(.status == "added") | .filename' \
31+
| grep -E "$expected" \
32+
|| true)
33+
if [ -z "$matching" ]; then
34+
echo "::error::PR must add a file named 'changelog.d/${PR_NUMBER}.<type>.md' or carry the 'no changelog' label."
35+
echo "See changelog.d/README.md for how to create an entry."
36+
exit 1
37+
fi
38+
echo "Found new changelog entry/entries:"
39+
echo "$matching"

0 commit comments

Comments
 (0)