This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (61 loc) · 2.37 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Pull request changelog
on:
pull_request_target:
types: [labeled, unlabeled, synchronize]
jobs:
check-changelog:
name: 'check changelog'
runs-on: ubuntu-latest
steps:
- name: Check if version label is present
id: labels
uses: actions/github-script@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const versionLabels = [
'Action: no bump',
'Action: beta bump',
'Action: patch bump',
'Action: minor bump',
'Action: major bump',
];
const { data: pullLabels } = await github.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
per_page: 100,
});
const labels = pullLabels.map(label => label.name);
const versionLabelsPresent = labels
.filter(name => versionLabels.includes(name));
console.log(`::debug ::${versionLabelsPresent.length} matching labels`);
if (versionLabelsPresent.length !== 1) {
throw new Error('Should have one and only one version bump label');
}
const versionLabel = versionLabelsPresent[0];
console.log(`::set-output name=versionLabel::${versionLabel}`)
if (versionLabel === 'Action: no bump') {
return;
}
- name: Fail if no changelog change when needed
if: |
steps.labels.outputs.versionLabel != 'Action: no bump'
&& steps.labels.outputs.versionLabel != 'Action: beta bump'
uses: actions/github-script@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
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 changelogFile = 'CHANGELOG.md';
const fileNotDeletedNames = files
.filter(file => file.status === 'added' || file.status === 'modified')
.map(file => file.filename);
if (!fileNotDeletedNames.includes(changelogFile)) {
throw new Error('CHANGELOG.md Unreleased section shoud have line additions when PR is not a no-release')
}