-
Notifications
You must be signed in to change notification settings - Fork 46
39 lines (32 loc) · 1.6 KB
/
enforce-pr-labels.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
name: Enforce PR Labels
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize, reopened]
jobs:
check-release-type-labels:
runs-on: ubuntu-latest
steps:
- name: Check for at least one release-type label
uses: actions/github-script@v6
with:
script: |
const requiredLabels = ['notes:feature', 'notes:enhancement', 'notes:bug-fix', 'notes:chore', 'notes:dependencies', 'notes:measure-update', 'notes:mvp-update', 'notes:benchmark-update'];
const prLabels = context.payload.pull_request.labels.map(label => label.name);
const hasAtLeastOneRequiredLabel = requiredLabels.some(label => prLabels.includes(label));
if (!hasAtLeastOneRequiredLabel) {
core.setFailed(`PR must have at least one of these labels for placement in release notes: ${requiredLabels.join(', ')}`);
}
check-version-labels:
needs: check-release-type-labels
runs-on: ubuntu-latest
steps:
- name: Check for at least one release-type label
uses: actions/github-script@v6
with:
script: |
const requiredLabels = ['version:patch', 'version:minor', 'version:major'];
const prLabels = context.payload.pull_request.labels.map(label => label.name);
const hasAtLeastOneRequiredLabel = requiredLabels.some(label => prLabels.includes(label));
if (!hasAtLeastOneRequiredLabel) {
core.setFailed(`Also, PR must have at least one of these labels for auto bumping of the release version number: ${requiredLabels.join(', ')}`);
}