Testing Auto Label v6 #8
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
name: Auto-label issues based on severity | |
on: | |
issues: | |
types: [opened, edited] | |
jobs: | |
label-issues: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Determine severity and apply labels | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Checking issue body for severity..." | |
issue_body=$(jq -r '.issue.body' "$GITHUB_EVENT_PATH") | |
echo "Issue Body: $issue_body" | |
# Use a regex to match the severity field | |
severity=$(echo "$issue_body" | grep -oP '(?<=### Severity\s*\n\n).+') | |
echo "Detected Severity: $severity" | |
if [[ "$severity" =~ [Cc]ritical ]]; then | |
labels="Severity: Critical,blocker" | |
elif [[ "$severity" =~ [Hh]igh ]]; then | |
labels="Severity: High" | |
elif [[ "$severity" =~ [Mm]edium ]]; then | |
labels="Severity: Medium" | |
elif [[ "$severity" =~ [Ll]ow ]]; then | |
labels="Severity: Low" | |
else | |
labels="" | |
fi | |
if [[ -n "$labels" ]]; then | |
echo "Applying labels: $labels" | |
gh issue edit ${{ github.event.issue.number }} --add-label "$labels" | |
else | |
echo "No severity label found." | |
fi |