name: Claude Oncall Issue Triage description: Identify critical issues that require oncall attention on: issues: types: [opened, edited, reopened] issue_comment: types: [created] schedule: # Run every 6 hours to catch issues that recently crossed the threshold - cron: '0 */6 * * *' workflow_dispatch: # Allow manual trigger jobs: oncall-triage: runs-on: ubuntu-latest timeout-minutes: 10 permissions: contents: read issues: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Create oncall triage prompt run: | mkdir -p /tmp/claude-prompts cat > /tmp/claude-prompts/oncall-triage-prompt.txt << 'EOF' You're an oncall triage assistant for GitHub issues. Your task is to identify critical issues that require immediate oncall attention. IMPORTANT: Don't post any comments or messages to the issues. Your only action should be to apply the "oncall" label to qualifying issues. Repository: ${{ github.repository }} Triggered by: ${{ github.event_name }} Issue number (if triggered by issue event or comment): ${{ github.event.issue.number }} TASK OVERVIEW: 1. Determine which issues to process: - If this workflow was triggered by an issue event or comment (issue number provided above), process ONLY that issue - This includes NEW comments on OLDER issues - they may now qualify for oncall if they meet the criteria - If triggered by schedule or manual trigger, use mcp__github__search_issues to find issues created in the last 7 days (use query: "is:issue is:open created:>=$(date -d '7 days ago' +%Y-%m-%d)") - This keeps the dataset small and focused on recent activity 2. For each issue to process, gather information using GitHub MCP tools: - Issue details (title, body, labels) using mcp__github__get_issue - All comments using mcp__github__get_issue_comments - Reaction counts from the reactionGroups field 3. Evaluate each issue against the oncall criteria. An issue is oncall-worthy if ALL of the following are true: a) Must be a bug: - The issue has a "bug" label OR - The issue content clearly describes a bug (error, crash, unexpected behavior) b) Must be blocking users from using Claude Code: - Look for keywords indicating severity: "crash", "stuck", "frozen", "hang", "unresponsive", "cannot use", "blocked", "broken" - The issue prevents core functionality from working - Users cannot work around the issue c) Last activity is within the last 3 days: - Check the issue's updated_at timestamp - Calculate if it was updated within the last 72 hours from now - Activity includes: new comments, reactions, or label changes d) At least 5 engagements: - Count total reactions from the reactionGroups field (sum all reaction counts) - Count total number of comments - Sum must be >= 5 4. For issues that meet ALL criteria above AND don't already have the "oncall" label: - Use mcp__github__update_issue to add the "oncall" label - DO NOT post any comments - DO NOT remove any existing labels 5. Do NOT remove the "oncall" label from any issues IMPORTANT GUIDELINES: - Be conservative in your assessment - only flag truly critical blocking issues - ALL four criteria must be met for an issue to receive the "oncall" label - DO NOT post any comments to issues - Your ONLY action should be to apply the "oncall" label using mcp__github__update_issue - Only add the label, never remove it - Process efficiently - only check recent issues (last 7 days) when running on schedule EOF - name: Setup GitHub MCP Server run: | mkdir -p /tmp/mcp-config cat > /tmp/mcp-config/mcp-servers.json << 'EOF' { "mcpServers": { "github": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server:sha-7aced2b" ], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${{ secrets.GITHUB_TOKEN }}" } } } } EOF - name: Run Claude Code for Oncall Triage uses: anthropics/claude-code-base-action@beta with: prompt_file: /tmp/claude-prompts/oncall-triage-prompt.txt allowed_tools: "mcp__github__search_issues,mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue" timeout_minutes: "10" anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} mcp_config: /tmp/mcp-config/mcp-servers.json claude_env: | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}