Skip to content

Commit

Permalink
add workflow to label feature ideas
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryun1 committed Aug 12, 2024
1 parent e2ba94c commit 4e99c29
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 2 deletions.
22 changes: 20 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_idea.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 💡 Feature idea
description: Idea or request for some feature on the GovTool roadmap
labels: ['💡 Feature idea']
title: "💡 "
projects: ["IntersectMBO/projects/30", "IntersectMBO/projects/34"]
body:
- type: markdown
attributes:
Expand All @@ -14,7 +15,7 @@ body:
- type: dropdown
id: area
attributes:
label: Feature area
label: Area
description: What part of GovTool does this feature affect?
options:
- Proposal Pillar
Expand All @@ -26,6 +27,18 @@ body:
validations:
required: true

- type: dropdown
id: design-needed
attributes:
label: Is there new design needed?
description: Will this feature require new or edit to existing frontend designs?
options:
- 'Yes'
- 'No'
- Not sure
validations:
required: true

- type: textarea
id: what
attributes:
Expand Down Expand Up @@ -58,6 +71,11 @@ body:
validations:
required: true

- type: markdown
attributes:
value: |
---
- type: textarea
id: user-story
attributes:
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/label-feature-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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"],
});
}

0 comments on commit 4e99c29

Please sign in to comment.