# This workflow assists in evaluating the severity of incoming issues to help # with triaging tickets. It uses AI analysis to classify issues into severity levels # (s0-s4) when the 'triage-check' label is applied. name: Classify Issue Severity on: issues: types: [labeled] workflow_dispatch: inputs: issue_url: description: "Issue URL to classify" required: true type: string template_preset: description: "Template preset to use" required: false default: "" type: string permissions: contents: read jobs: classify-severity: name: AI Severity Classification runs-on: ubuntu-latest if: | (github.event.label.name == 'triage-check' || github.event_name == 'workflow_dispatch') timeout-minutes: 30 env: CODER_URL: ${{ secrets.DOC_CHECK_CODER_URL }} CODER_SESSION_TOKEN: ${{ secrets.DOC_CHECK_CODER_SESSION_TOKEN }} permissions: contents: read issues: write steps: - name: Determine Issue Context id: determine-context env: GITHUB_ACTOR: ${{ github.actor }} GITHUB_EVENT_NAME: ${{ github.event_name }} GITHUB_EVENT_ISSUE_HTML_URL: ${{ github.event.issue.html_url }} GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }} GITHUB_EVENT_SENDER_ID: ${{ github.event.sender.id }} GITHUB_EVENT_SENDER_LOGIN: ${{ github.event.sender.login }} INPUTS_ISSUE_URL: ${{ inputs.issue_url }} INPUTS_TEMPLATE_PRESET: ${{ inputs.template_preset || '' }} GH_TOKEN: ${{ github.token }} run: | echo "Using template preset: ${INPUTS_TEMPLATE_PRESET}" echo "template_preset=${INPUTS_TEMPLATE_PRESET}" >> "${GITHUB_OUTPUT}" # For workflow_dispatch, use the provided issue URL if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then if ! GITHUB_USER_ID=$(gh api "users/${GITHUB_ACTOR}" --jq '.id'); then echo "::error::Failed to get GitHub user ID for actor ${GITHUB_ACTOR}" exit 1 fi echo "Using workflow_dispatch actor: ${GITHUB_ACTOR} (ID: ${GITHUB_USER_ID})" echo "github_user_id=${GITHUB_USER_ID}" >> "${GITHUB_OUTPUT}" echo "github_username=${GITHUB_ACTOR}" >> "${GITHUB_OUTPUT}" echo "Using issue URL: ${INPUTS_ISSUE_URL}" echo "issue_url=${INPUTS_ISSUE_URL}" >> "${GITHUB_OUTPUT}" # Extract issue number from URL for later use ISSUE_NUMBER=$(echo "${INPUTS_ISSUE_URL}" | grep -oP '(?<=issues/)\d+') echo "issue_number=${ISSUE_NUMBER}" >> "${GITHUB_OUTPUT}" elif [[ "${GITHUB_EVENT_NAME}" == "issues" ]]; then GITHUB_USER_ID=${GITHUB_EVENT_SENDER_ID} echo "Using label adder: ${GITHUB_EVENT_SENDER_LOGIN} (ID: ${GITHUB_USER_ID})" echo "github_user_id=${GITHUB_USER_ID}" >> "${GITHUB_OUTPUT}" echo "github_username=${GITHUB_EVENT_SENDER_LOGIN}" >> "${GITHUB_OUTPUT}" echo "Using issue URL: ${GITHUB_EVENT_ISSUE_HTML_URL}" echo "issue_url=${GITHUB_EVENT_ISSUE_HTML_URL}" >> "${GITHUB_OUTPUT}" echo "issue_number=${GITHUB_EVENT_ISSUE_NUMBER}" >> "${GITHUB_OUTPUT}" else echo "::error::Unsupported event type: ${GITHUB_EVENT_NAME}" exit 1 fi - name: Build Classification Prompt id: build-prompt env: ISSUE_URL: ${{ steps.determine-context.outputs.issue_url }} ISSUE_NUMBER: ${{ steps.determine-context.outputs.issue_number }} GH_TOKEN: ${{ github.token }} run: | echo "Analyzing issue #${ISSUE_NUMBER}" # Build task prompt - using unquoted heredoc so variables expand TASK_PROMPT=$(cat <> "${GITHUB_OUTPUT}" - name: Checkout create-task-action uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 1 path: ./.github/actions/create-task-action persist-credentials: false ref: main repository: coder/create-task-action - name: Create Coder Task for Severity Classification id: create_task uses: ./.github/actions/create-task-action with: coder-url: ${{ secrets.DOC_CHECK_CODER_URL }} coder-token: ${{ secrets.DOC_CHECK_CODER_SESSION_TOKEN }} coder-organization: "default" coder-template-name: coder coder-template-preset: ${{ steps.determine-context.outputs.template_preset }} coder-task-name-prefix: severity-classification coder-task-prompt: ${{ steps.build-prompt.outputs.task_prompt }} github-user-id: ${{ steps.determine-context.outputs.github_user_id }} github-token: ${{ github.token }} github-issue-url: ${{ steps.determine-context.outputs.issue_url }} comment-on-issue: true - name: Write outputs env: TASK_CREATED: ${{ steps.create_task.outputs.task-created }} TASK_NAME: ${{ steps.create_task.outputs.task-name }} TASK_URL: ${{ steps.create_task.outputs.task-url }} ISSUE_URL: ${{ steps.determine-context.outputs.issue_url }} run: | { echo "## Severity Classification Task" echo "" echo "**Issue:** ${ISSUE_URL}" echo "**Task created:** ${TASK_CREATED}" echo "**Task name:** ${TASK_NAME}" echo "**Task URL:** ${TASK_URL}" echo "" echo "The Coder task is analyzing the issue and will comment with severity classification." } >> "${GITHUB_STEP_SUMMARY}"