-
Notifications
You must be signed in to change notification settings - Fork 42
52 lines (47 loc) · 1.81 KB
/
Copy pathchangelog.yml
File metadata and controls
52 lines (47 loc) · 1.81 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
name: Changelog
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
jobs:
check:
runs-on: ubuntu-latest
name: Check
steps:
- name: Check for skip-changelog label
id: skip
run: |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'skip-changelog') }}" == "true" ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Get changed files
if: steps.skip.outputs.skip == 'false'
id: changed
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const files = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
per_page: 100
});
const hasChangelog = files.some(f => f.filename === 'CHANGELOG.md');
core.setOutput('has_changelog', hasChangelog);
- name: Require changelog entry
if: steps.skip.outputs.skip == 'false' && steps.changed.outputs.has_changelog != 'true'
run: |
echo "::error::Please add an entry to CHANGELOG.md describing your changes."
echo ""
echo "If this is a chore PR that doesn't need a changelog entry,"
echo "add the 'skip-changelog' label to skip this check."
exit 1
- name: Changelog check passed
if: steps.skip.outputs.skip == 'true' || steps.changed.outputs.has_changelog == 'true'
run: |
if [[ "${{ steps.skip.outputs.skip }}" == "true" ]]; then
echo "Skipped: 'skip-changelog' label is present"
else
echo "CHANGELOG.md was updated"
fi