forked from nulang-org/nulang
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.71 KB
/
Copy pathchangelog.yml
File metadata and controls
76 lines (65 loc) · 2.71 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
name: Changelog Check
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
# Only check PRs that introduce user-visible changes.
# Draft PRs are exempt until marked ready.
permissions:
contents: read
jobs:
check-changelog:
name: Changelog updated?
# Skip for draft PRs and for changes that don't need a changelog entry.
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine if changelog update is needed
id: check
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
PR_LABELS="${{ toJson(github.event.pull_request.labels.*.name) }}"
# Types that always need a changelog entry
if echo "$PR_TITLE" | grep -qiE "^(feat|fix|perf)(\(|:)"; then
echo "needed=true" >> "$GITHUB_OUTPUT"
echo "reason=PR title indicates a user-visible change (feat/fix/perf)"
exit 0
fi
# Types that never need a changelog entry
if echo "$PR_TITLE" | grep -qiE "^(chore|ci|style|refactor|test|docs)(\(|:)"; then
echo "needed=false" >> "$GITHUB_OUTPUT"
echo "reason=PR title indicates an internal change (${PR_TITLE%%:*})"
exit 0
fi
# Check for skip-changelog label
if echo "$PR_LABELS" | grep -qi "skip-changelog"; then
echo "needed=false" >> "$GITHUB_OUTPUT"
echo "reason=skip-changelog label present"
exit 0
fi
# Conservative: require changelog for unknown types
echo "needed=true" >> "$GITHUB_OUTPUT"
echo "reason=unknown PR type, changelog required by default"
- name: Verify CHANGELOG.md was modified
if: steps.check.outputs.needed == 'true'
run: |
git fetch origin "${{ github.base_ref }}" --depth=1
if git diff --name-only "origin/${{ github.base_ref }}...HEAD" | grep -q "^CHANGELOG.md$"; then
echo "✓ CHANGELOG.md updated"
exit 0
fi
echo ""
echo " ERROR: CHANGELOG.md must be updated for this change."
echo " Reason: ${{ steps.check.outputs.reason }}"
echo ""
echo " If this change does not need a changelog entry:"
echo " 1. Add the 'skip-changelog' label to this PR, or"
echo " 2. Change the PR title to use chore/ci/style/refactor/test/docs"
echo ""
exit 1
- name: Changelog not required (info)
if: steps.check.outputs.needed == 'false'
run: |
echo "✓ Changelog update not required: ${{ steps.check.outputs.reason }}"