-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing adding an auto label test
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Auto-label issues based on severity | ||
|
||
on: | ||
issues: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
label-issues: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Label issues based on severity | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const issueBody = context.payload.issue.body; | ||
const severityRegex = /Severity \*\n(?:.*\n)*?\* (.*?)\n/g; | ||
const severityMatch = severityRegex.exec(issueBody); | ||
const labels = []; | ||
if (severityMatch) { | ||
const severity = severityMatch[1].toLowerCase(); | ||
if (severity.includes("critical")) { | ||
labels.push('Severity: Critical', 'blocker'); | ||
} else if (severity.includes("high")) { | ||
labels.push('Severity: High'); | ||
} else if (severity.includes("medium")) { | ||
labels.push('Severity: Medium'); | ||
} else if (severity.includes("low")) { | ||
labels.push('Severity: Low'); | ||
} | ||
} | ||
if (labels.length > 0) { | ||
await github.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.issue.number, | ||
labels: labels | ||
}); | ||
} |