diff --git a/.github/workflows/auto-label-issues.yml b/.github/workflows/auto-label-issues.yml index 120cfcd9..faab3e4e 100644 --- a/.github/workflows/auto-label-issues.yml +++ b/.github/workflows/auto-label-issues.yml @@ -10,6 +10,16 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + + - name: Install GitHub CLI + run: | + type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && sudo apt update \ + && sudo apt install gh -y + - name: Determine severity and apply labels env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -17,23 +27,34 @@ jobs: 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).+') + # Extract the severity from the dropdown selection + severity=$(echo "$issue_body" | sed -n 's/.*### Severity \*\s*\n\n\(.*\)/\1/p' | sed 's/^- //') 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 + case "$severity" in + "Critical (Game-breaking/Crash): The game crashes or a core feature (like saving, loading, or network connection) is completely unusable.") + labels="Severity: Critical,blocker" + ;; + "High (Major Disruption): A major feature is broken or incorrect, but a workaround exists.") + labels="Severity: High" + ;; + "Medium (Gameplay Limitation): Non-core functionality is impaired, providing a suboptimal but playable experience.") + labels="Severity: Medium" + ;; + "Low (Minor/Nuisance): Minor glitches or cosmetic issues that don't affect gameplay and occur rarely.") + labels="Severity: Low" + ;; + *) + labels="" + ;; + esac if [[ -n "$labels" ]]; then echo "Applying labels: $labels" - gh issue edit ${{ github.event.issue.number }} --add-label "$labels" + if gh issue edit ${{ github.event.issue.number }} --add-label "$labels"; then + echo "Labels applied successfully" + else + echo "Failed to apply labels" + exit 1 + fi else - echo "No severity label found." + echo "No severity label found or unrecognized severity." fi