generated from iadvize/hello-world-javascript-library
-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (43 loc) · 1.67 KB
/
pull-changelog.yml
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: Pull request changelog
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
jobs:
changelog:
name: 'check changelog change'
runs-on: ubuntu-18.04
steps:
- name: Fail if no changelog change when needed
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labelsWhereChangelogChangeIsRequired = [
'Action: patch bump',
'Action: minor bump',
'Action: major bump',
];
const { data: labels } = await github.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
per_page: 100,
});
const matchingLabels = labels
.filter(label => labelsWhereChangelogChangeIsRequired.includes(label.name))
if (matchingLabels.length === 0) {
console.log('::debug ::No label requiring changelog change. Nothing to do')
return;
}
const { data: files } = await github.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
});
const fileNotDeletedNames = files
.filter(file => file.status === 'added' || file.status === 'modified')
.map(file => file.filename)
if (!fileNotDeletedNames.includes('CHANGELOG.md')) {
throw new Error('CHANGELOG.md Unreleased section shoud have line additions when PR is not a no-release')
}