|
| 1 | +name: AI Agent - Label Triggered Analysis |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +jobs: |
| 8 | + label-triggered-analysis: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + if: github.event_name == 'issues' && github.event.action == 'labeled' |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + |
| 18 | + - name: Install Ripgrep |
| 19 | + run: sudo apt-get update && sudo apt-get install -y ripgrep |
| 20 | + |
| 21 | + - name: Setup Node.js |
| 22 | + uses: actions/setup-node@v4 |
| 23 | + with: |
| 24 | + node-version: '20' |
| 25 | + |
| 26 | + - name: Install pnpm |
| 27 | + uses: pnpm/action-setup@v4 |
| 28 | + with: |
| 29 | + version: 8 |
| 30 | + |
| 31 | + - name: Install workspace dependencies |
| 32 | + run: pnpm install |
| 33 | + |
| 34 | + - name: Build packages in correct order |
| 35 | + run: | |
| 36 | + pnpm --filter worker-core build |
| 37 | + pnpm --filter worker-protobuf build |
| 38 | + pnpm --filter context-worker build |
| 39 | + pnpm --filter github-agent build |
| 40 | +
|
| 41 | + - name: Label-Specific AI Analysis |
| 42 | + timeout-minutes: 10 |
| 43 | + run: | |
| 44 | + cd packages/github-agent |
| 45 | + |
| 46 | + LABEL_NAME="${{ github.event.label.name }}" |
| 47 | + ISSUE_NUMBER="${{ github.event.issue.number }}" |
| 48 | + REPOSITORY="${{ github.repository }}" |
| 49 | + |
| 50 | + echo "🏷️ Label '$LABEL_NAME' added to issue #$ISSUE_NUMBER" |
| 51 | + echo "🎯 Repository: $REPOSITORY" |
| 52 | + echo "📋 Issue Title: ${{ github.event.issue.title }}" |
| 53 | + echo "" |
| 54 | + |
| 55 | + # Set timeout and error handling |
| 56 | + set -e |
| 57 | + trap 'echo "❌ Label analysis interrupted or timed out"; exit 1' INT TERM |
| 58 | + |
| 59 | + # The agent.js will automatically detect the labeled event and generate appropriate analysis |
| 60 | + timeout 480s node bin/agent.js --auto-upload --verbose --workspace "${{ github.workspace }}" \ |
| 61 | + --command "Smart analysis triggered by label" || { |
| 62 | + echo "⚠️ Label-triggered analysis timed out or failed, but continuing..." |
| 63 | + exit 0 |
| 64 | + } |
| 65 | + |
| 66 | + echo "✅ Label-triggered analysis completed successfully" |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 70 | + DEEPSEEK_TOKEN: ${{ secrets.DEEPSEEK_TOKEN }} |
| 71 | + GLM_TOKEN: ${{ secrets.GLM_TOKEN }} |
| 72 | + NODE_OPTIONS: "--max-old-space-size=4096" |
| 73 | + # GitHub Actions context variables |
| 74 | + GITHUB_ACTIONS: true |
| 75 | + GITHUB_REPOSITORY: ${{ github.repository }} |
| 76 | + GITHUB_EVENT_NAME: ${{ github.event_name }} |
| 77 | + GITHUB_EVENT_PATH: ${{ github.event_path }} |
| 78 | + |
| 79 | + # Special handling for critical labels |
| 80 | + critical-label-analysis: |
| 81 | + runs-on: ubuntu-latest |
| 82 | + if: | |
| 83 | + github.event_name == 'issues' && |
| 84 | + github.event.action == 'labeled' && |
| 85 | + (github.event.label.name == 'critical' || |
| 86 | + github.event.label.name == 'security' || |
| 87 | + github.event.label.name == 'breaking-change') |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Checkout repository |
| 91 | + uses: actions/checkout@v4 |
| 92 | + with: |
| 93 | + fetch-depth: 0 |
| 94 | + |
| 95 | + - name: Setup Node.js |
| 96 | + uses: actions/setup-node@v4 |
| 97 | + with: |
| 98 | + node-version: '20' |
| 99 | + |
| 100 | + - name: Install pnpm |
| 101 | + uses: pnpm/action-setup@v4 |
| 102 | + with: |
| 103 | + version: 8 |
| 104 | + |
| 105 | + - name: Install workspace dependencies |
| 106 | + run: pnpm install |
| 107 | + |
| 108 | + - name: Build packages |
| 109 | + run: | |
| 110 | + pnpm --filter worker-core build |
| 111 | + pnpm --filter worker-protobuf build |
| 112 | + pnpm --filter context-worker build |
| 113 | + pnpm --filter github-agent build |
| 114 | +
|
| 115 | + - name: Critical Issue Deep Analysis |
| 116 | + timeout-minutes: 15 |
| 117 | + run: | |
| 118 | + cd packages/github-agent |
| 119 | + |
| 120 | + LABEL_NAME="${{ github.event.label.name }}" |
| 121 | + ISSUE_NUMBER="${{ github.event.issue.number }}" |
| 122 | + |
| 123 | + echo "🚨 CRITICAL: Issue #$ISSUE_NUMBER labeled with '$LABEL_NAME'" |
| 124 | + echo "🔍 Performing deep analysis for critical issue..." |
| 125 | + |
| 126 | + # Extended timeout for critical issues |
| 127 | + timeout 720s node bin/agent.js --auto-upload --verbose --workspace "${{ github.workspace }}" \ |
| 128 | + --command "CRITICAL ANALYSIS: Issue #$ISSUE_NUMBER has been marked as $LABEL_NAME. Perform comprehensive deep analysis with maximum detail and urgency." || { |
| 129 | + echo "⚠️ Critical analysis timed out or failed" |
| 130 | + exit 1 |
| 131 | + } |
| 132 | + env: |
| 133 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 134 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 135 | + DEEPSEEK_TOKEN: ${{ secrets.DEEPSEEK_TOKEN }} |
| 136 | + GLM_TOKEN: ${{ secrets.GLM_TOKEN }} |
| 137 | + NODE_OPTIONS: "--max-old-space-size=6144" |
| 138 | + GITHUB_ACTIONS: true |
| 139 | + GITHUB_REPOSITORY: ${{ github.repository }} |
| 140 | + GITHUB_EVENT_NAME: ${{ github.event_name }} |
| 141 | + GITHUB_EVENT_PATH: ${{ github.event_path }} |
| 142 | + |
| 143 | + - name: Notify Team for Critical Issues |
| 144 | + if: success() |
| 145 | + uses: actions/github-script@v7 |
| 146 | + with: |
| 147 | + script: | |
| 148 | + const labelName = '${{ github.event.label.name }}'; |
| 149 | + const issueNumber = ${{ github.event.issue.number }}; |
| 150 | + |
| 151 | + let notificationMessage = ''; |
| 152 | + if (labelName === 'critical') { |
| 153 | + notificationMessage = '🚨 **CRITICAL ISSUE ALERT** - This issue requires immediate attention from the development team.'; |
| 154 | + } else if (labelName === 'security') { |
| 155 | + notificationMessage = '🔒 **SECURITY ALERT** - This issue has security implications and needs urgent review.'; |
| 156 | + } else if (labelName === 'breaking-change') { |
| 157 | + notificationMessage = '💥 **BREAKING CHANGE ALERT** - This issue involves breaking changes that need careful coordination.'; |
| 158 | + } |
| 159 | + |
| 160 | + if (notificationMessage) { |
| 161 | + await github.rest.issues.createComment({ |
| 162 | + issue_number: issueNumber, |
| 163 | + owner: context.repo.owner, |
| 164 | + repo: context.repo.repo, |
| 165 | + body: `${notificationMessage}\n\nAI analysis has been triggered and will be posted shortly.` |
| 166 | + }); |
| 167 | + } |
| 168 | +
|
| 169 | + # Special handling for newcomer-friendly labels |
| 170 | + newcomer-friendly-analysis: |
| 171 | + runs-on: ubuntu-latest |
| 172 | + if: | |
| 173 | + github.event_name == 'issues' && |
| 174 | + github.event.action == 'labeled' && |
| 175 | + (github.event.label.name == 'good-first-issue' || |
| 176 | + github.event.label.name == 'help-wanted' || |
| 177 | + github.event.label.name == 'beginner-friendly') |
| 178 | + |
| 179 | + steps: |
| 180 | + - name: Checkout repository |
| 181 | + uses: actions/checkout@v4 |
| 182 | + |
| 183 | + - name: Setup Node.js |
| 184 | + uses: actions/setup-node@v4 |
| 185 | + with: |
| 186 | + node-version: '20' |
| 187 | + |
| 188 | + - name: Install pnpm |
| 189 | + uses: pnpm/action-setup@v4 |
| 190 | + with: |
| 191 | + version: 8 |
| 192 | + |
| 193 | + - name: Install workspace dependencies |
| 194 | + run: pnpm install |
| 195 | + |
| 196 | + - name: Build packages |
| 197 | + run: | |
| 198 | + pnpm --filter worker-core build |
| 199 | + pnpm --filter worker-protobuf build |
| 200 | + pnpm --filter context-worker build |
| 201 | + pnpm --filter github-agent build |
| 202 | +
|
| 203 | + - name: Newcomer-Friendly Analysis |
| 204 | + run: | |
| 205 | + cd packages/github-agent |
| 206 | + |
| 207 | + echo "👋 Generating newcomer-friendly analysis for issue #${{ github.event.issue.number }}" |
| 208 | + |
| 209 | + # The smart command generation will handle newcomer-specific analysis |
| 210 | + node bin/agent.js --auto-upload --verbose --workspace "${{ github.workspace }}" \ |
| 211 | + --command "Newcomer guidance analysis" |
| 212 | + env: |
| 213 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 214 | + DEEPSEEK_TOKEN: ${{ secrets.DEEPSEEK_TOKEN }} |
| 215 | + GITHUB_ACTIONS: true |
| 216 | + GITHUB_REPOSITORY: ${{ github.repository }} |
| 217 | + GITHUB_EVENT_NAME: ${{ github.event_name }} |
| 218 | + GITHUB_EVENT_PATH: ${{ github.event_path }} |
| 219 | + |
| 220 | + - name: Add Newcomer Welcome Comment |
| 221 | + uses: actions/github-script@v7 |
| 222 | + with: |
| 223 | + script: | |
| 224 | + await github.rest.issues.createComment({ |
| 225 | + issue_number: ${{ github.event.issue.number }}, |
| 226 | + owner: context.repo.owner, |
| 227 | + repo: context.repo.repo, |
| 228 | + body: `👋 **Welcome Contributors!** |
| 229 | +
|
| 230 | +This issue has been marked as beginner-friendly. Our AI agent is analyzing the issue and will provide detailed guidance shortly. |
| 231 | + |
| 232 | +**For new contributors:** |
| 233 | +- 📚 Check our [Contributing Guide](../blob/master/CONTRIBUTING.md) if available |
| 234 | +- 💬 Feel free to ask questions in the comments |
| 235 | +- 🤝 Don't hesitate to request help or clarification |
| 236 | + |
| 237 | +The AI analysis will include step-by-step guidance and learning resources to help you get started!` |
| 238 | + }); |
0 commit comments