-
Notifications
You must be signed in to change notification settings - Fork 9
92 lines (78 loc) · 3.11 KB
/
label-feature-issue.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
name: Add labels to 💡 Feature idea issues
on:
issues:
types: [opened, edited]
permissions:
issues: write
contents: read
jobs:
apply-labels:
runs-on: ubuntu-latest
steps:
- name: Check if issue is a "💡 Feature idea"
id: check_is_feature_idea
run: |
echo "## Checking if issue is a 'Feature idea'..."
if [[ "${{ github.event.issue.title }}" == "💡 "* ]]; then
echo "is_feature_idea=true" >> $GITHUB_ENV
else
echo "is_feature_idea=false" >> $GITHUB_ENV
fi
- name: Apply label based on feature area
if: ${{ env.is_feature_idea == 'true' }}
uses: actions/github-script@v6
with:
script: |
const areaMap = {
"Proposal Pillar": "📜 Proposal Pillar",
"Voting Pillar": "🗳️ Voting Pillar",
"Delegation Pillar": "♟️ Delegation Pillar",
"Wrapper": "🎁 Wrapper",
"Other": "Other area",
"Not sure": "❓Unknown area",
};
const issueBody = context.payload.issue.body;
// Match the Area selected under the "### Area" header
const areaMatch = issueBody.match(/### Area\s*\n\s*(.*)\s*\n/);
const area = areaMatch ? areaMatch[1].trim() : null;
const labelToAdd = areaMap[area];
if (labelToAdd) {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [labelToAdd],
});
}
- name: Apply "🎨 Design Needed" label if design needed is "Yes"
if: ${{ env.is_feature_idea == 'true' }}
uses: actions/github-script@v6
with:
script: |
const issueBody = context.payload.issue.body;
// Match the "Yes" selection under the "### Is there new design needed?" header
const designNeededMatch = issueBody.match(/### Is there new design needed\?\s*\n\s*Yes\s*\n/);
if (designNeededMatch) {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["🎨 Design Needed"],
});
}
- name: Apply "User Story Needed" label if user story not provided
if: ${{ env.is_feature_idea == 'true' }}
uses: actions/github-script@v6
with:
script: |
const issueBody = context.payload.issue.body;
const userStoryPattern = /### \(Optional\) User Story with acceptance criteria\s*\n\s*_No response_/;
const userStoryMissing = userStoryPattern.test(issueBody);
if (userStoryMissing) {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["User Story Needed"],
});
}