-
Notifications
You must be signed in to change notification settings - Fork 4
51 lines (44 loc) · 1.56 KB
/
repository-create-epic-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
---
name: Create epic label
on: # yamllint disable-line rule:truthy
issues:
types:
- labeled
concurrency:
group: create-epic-label
cancel-in-progress: true
permissions: read-all
jobs:
create-epic-label:
if: github.event.label.name == 'Epic'
name: Create epic label
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Create epic label
id: create_epic_label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issueTitle = context.payload.issue.title;
const issueNumber = context.payload.issue.number;
const labelName = `${issueTitle} (Epic #${issueNumber})`;
const labels = context.payload.issue.labels;
// Generate a random 6-digit hexadecimal color
const randomColor = Math.floor(Math.random()*16777215).toString(16);
// Check if label already exists
const existingLabels = await github.paginate(github.rest.issues.listLabelsForRepo, {
owner: context.repo.owner,
repo: context.repo.repo
});
if (!existingLabels.find(label => label.name === labelName)) {
// Label doesn't exist, create it
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: labelName,
color: randomColor
});
}