-
Notifications
You must be signed in to change notification settings - Fork 138
93 lines (87 loc) · 3.12 KB
/
conventional-label.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
on:
pull_request_target:
types: [opened, edited, synchronize, reopened]
permissions:
pull-requests: write
name: Auto label pull request
jobs:
pr-label:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: "Confirm correct pull request title"
uses: mmubeen/action-pr-title@master # until PR gets merged https://github.com/deepakputhraya/action-pr-title/pull/29
with:
allowed_prefixes: "breaking,chore,feat,feature,fix,major,minor,enhancement,\
deprecated,removed,security,bug,bugfix,docs,packaging,\
test,refactor,refactoring,skip-release,skip_changelog,patch"
- name: "Apply label"
if: github.event.pull_request.labels.length == 0
uses: bcoe/conventional-release-labels@v1
with:
type_labels: |
{
"feature": "enhancement",
"feat": "enhancement",
"fix": "bugfix",
"major": "major",
"breaking": "breaking",
"minor": "minor",
"enhancement": "enhancement",
"deprecated": "deprecated",
"removed": "removed",
"security": "security",
"bug": "bug",
"bugfix": "bugfix",
"docs": "trivial",
"packaging": "trivial",
"test": "trivial",
"refactor": "trivial",
"refactoring": "trivial",
"skip-release": "skip_changelog",
"skip_changelog": "skip_changelog",
"patch": "trivial",
"chore": "trivial"
}
role-label:
runs-on: ubuntu-latest
needs: pr-label
if: github.event.pull_request.labels.length == 0
steps:
- uses: actions/checkout@v4
- name: Get changed roles
id: changed-roles
uses: tj-actions/changed-files@v45
with:
path: "roles"
diff_relative: "true"
files: "**"
dir_names: "true"
dir_names_max_depth: "1"
sha: ${{ github.event.pull_request.head.sha }}
- name: Add changed roles labels
uses: actions/github-script@v7
if: |
steps.changed-roles.outputs.all_changed_and_modified_files
with:
script: |
const changedRoles = '${{ steps.changed-roles.outputs.all_changed_and_modified_files }}'.split(' ');
let labels = changedRoles.map(i => 'roles/' + i);
if (changedRoles.includes('_common')) {
const allLabels = await github.paginate(github.rest.issues.listLabelsForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
});
const roleLabels = allLabels.map(label => label.name).filter(name => name.startsWith('roles/'));
labels = [...new Set([...labels, ...roleLabels])];
}
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
})