|
76 | 76 | - name: Notify Slack on agent failure |
77 | 77 | if: steps.agent.outcome != 'success' |
78 | 78 | run: | |
| 79 | + # Use jq to safely construct JSON payload |
| 80 | + TASK="${{ github.event.client_payload.task || github.event.client_payload.original_task }}" |
| 81 | + REQUESTER="${{ github.event.client_payload.requester }}" |
| 82 | + RUN_ID="${{ github.run_id }}" |
| 83 | + |
| 84 | + PAYLOAD=$(jq -n \ |
| 85 | + --arg text "❌ AICODE Agent failed before tests" \ |
| 86 | + --arg task "$TASK" \ |
| 87 | + --arg requester "$REQUESTER" \ |
| 88 | + --arg run_url "https://github.com/htilly/SlackONOS/actions/runs/$RUN_ID" \ |
| 89 | + '{ |
| 90 | + text: $text, |
| 91 | + blocks: [ |
| 92 | + { |
| 93 | + type: "section", |
| 94 | + text: { |
| 95 | + type: "mrkdwn", |
| 96 | + text: ("❌ *AICODE Agent Failed*\n\n*Task:* " + $task + "\n*Requested by:* " + $requester + "\n*Stage:* Agent execution\n\nCheck the logs for detailed error information.") |
| 97 | + } |
| 98 | + }, |
| 99 | + { |
| 100 | + type: "section", |
| 101 | + text: { |
| 102 | + type: "mrkdwn", |
| 103 | + text: ("<" + $run_url + "|View GitHub Actions logs>") |
| 104 | + } |
| 105 | + } |
| 106 | + ] |
| 107 | + }') |
| 108 | + |
79 | 109 | curl -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \ |
80 | 110 | -H "Content-Type: application/json" \ |
81 | | - -d "{\"text\":\"❌ AICODE Agent failed before tests\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"❌ *AICODE Agent Failed*\\n\\n*Task:* ${{ github.event.client_payload.task || github.event.client_payload.original_task }}\\n*Requested by:* ${{ github.event.client_payload.requester }}\\n*Stage:* Agent execution\\n\\nCheck the logs for detailed error information.\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"<https://github.com/htilly/SlackONOS/actions/runs/${{ github.run_id }}|View GitHub Actions logs>\"}}]}" |
| 111 | + -d "$PAYLOAD" |
82 | 112 |
|
83 | 113 | - name: Validate diff format |
84 | 114 | id: validate |
@@ -170,20 +200,112 @@ jobs: |
170 | 200 | if: steps.agent.outcome == 'success' && steps.tests.outcome == 'success' && steps.secrets-check.outcome == 'success' |
171 | 201 | run: | |
172 | 202 | CHANGED_FILES="${{ steps.changed-files.outputs.files }}" |
| 203 | + TASK="${{ github.event.client_payload.task || github.event.client_payload.original_task }}" |
| 204 | + ORIGINAL_TASK="${{ github.event.client_payload.original_task || 'N/A' }}" |
| 205 | + REQUESTER="${{ github.event.client_payload.requester }}" |
| 206 | + PR_NUMBER="${{ steps.cpr.outputs.pull-request-number }}" |
| 207 | + RUN_ID="${{ github.run_id }}" |
| 208 | + |
| 209 | + PAYLOAD=$(jq -n \ |
| 210 | + --arg text "✅ AICODE PR created: <https://github.com/htilly/SlackONOS/pull/$PR_NUMBER|#$PR_NUMBER>" \ |
| 211 | + --arg task "$TASK" \ |
| 212 | + --arg original_task "$ORIGINAL_TASK" \ |
| 213 | + --arg requester "$REQUESTER" \ |
| 214 | + --arg pr_number "$PR_NUMBER" \ |
| 215 | + --arg changed_files "$CHANGED_FILES" \ |
| 216 | + --arg run_id "$RUN_ID" \ |
| 217 | + '{ |
| 218 | + text: $text, |
| 219 | + blocks: [ |
| 220 | + { |
| 221 | + type: "section", |
| 222 | + text: { |
| 223 | + type: "mrkdwn", |
| 224 | + text: ("✅ *AICODE Agent Success*\n\n*Task:* " + $task + "\n*Original:* " + $original_task + "\n*Requested by:* " + $requester + "\n*PR:* <https://github.com/htilly/SlackONOS/pull/" + $pr_number + "|#" + $pr_number + ">\n*Files changed:* " + $changed_files) |
| 225 | + } |
| 226 | + }, |
| 227 | + { |
| 228 | + type: "section", |
| 229 | + text: { |
| 230 | + type: "mrkdwn", |
| 231 | + text: ("<https://github.com/htilly/SlackONOS/actions/runs/" + $run_id + "|View workflow run>") |
| 232 | + } |
| 233 | + } |
| 234 | + ] |
| 235 | + }') |
| 236 | + |
173 | 237 | curl -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \ |
174 | 238 | -H "Content-Type: application/json" \ |
175 | | - -d "{\"text\":\"✅ AICODE PR created: <https://github.com/htilly/SlackONOS/pull/${{ steps.cpr.outputs.pull-request-number }}|#${{ steps.cpr.outputs.pull-request-number }}>\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"✅ *AICODE Agent Success*\\n\\n*Task:* ${{ github.event.client_payload.task || github.event.client_payload.original_task }}\\n*Original:* ${{ github.event.client_payload.original_task || 'N/A' }}\\n*Requested by:* ${{ github.event.client_payload.requester }}\\n*PR:* <https://github.com/htilly/SlackONOS/pull/${{ steps.cpr.outputs.pull-request-number }}|#${{ steps.cpr.outputs.pull-request-number }}>\\n*Files changed:* ${CHANGED_FILES}\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"<https://github.com/htilly/SlackONOS/actions/runs/${{ github.run_id }}|View workflow run>\"}}]}" |
| 239 | + -d "$PAYLOAD" |
176 | 240 |
|
177 | 241 | - name: Notify Slack on validation failure |
178 | 242 | if: steps.agent.outcome == 'success' && steps.secrets-check.outcome != 'success' |
179 | 243 | run: | |
| 244 | + TASK="${{ github.event.client_payload.task || github.event.client_payload.original_task }}" |
| 245 | + REQUESTER="${{ github.event.client_payload.requester }}" |
| 246 | + RUN_ID="${{ github.run_id }}" |
| 247 | + |
| 248 | + PAYLOAD=$(jq -n \ |
| 249 | + --arg text "🔒 AICODE failed: Security validation failed" \ |
| 250 | + --arg task "$TASK" \ |
| 251 | + --arg requester "$REQUESTER" \ |
| 252 | + --arg run_id "$RUN_ID" \ |
| 253 | + '{ |
| 254 | + text: $text, |
| 255 | + blocks: [ |
| 256 | + { |
| 257 | + type: "section", |
| 258 | + text: { |
| 259 | + type: "mrkdwn", |
| 260 | + text: ("🔒 *AICODE Security Validation Failed*\n\n*Task:* " + $task + "\n*Requested by:* " + $requester + "\n*Issue:* Potential secrets detected in generated code\n\nReview the changes manually before proceeding.") |
| 261 | + } |
| 262 | + }, |
| 263 | + { |
| 264 | + type: "section", |
| 265 | + text: { |
| 266 | + type: "mrkdwn", |
| 267 | + text: ("<https://github.com/htilly/SlackONOS/actions/runs/" + $run_id + "|View GitHub Actions logs>") |
| 268 | + } |
| 269 | + } |
| 270 | + ] |
| 271 | + }') |
| 272 | + |
180 | 273 | curl -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \ |
181 | 274 | -H "Content-Type: application/json" \ |
182 | | - -d "{\"text\":\"🔒 AICODE failed: Security validation failed\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"🔒 *AICODE Security Validation Failed*\\n\\n*Task:* ${{ github.event.client_payload.task || github.event.client_payload.original_task }}\\n*Requested by:* ${{ github.event.client_payload.requester }}\\n*Issue:* Potential secrets detected in generated code\\n\\nReview the changes manually before proceeding.\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"<https://github.com/htilly/SlackONOS/actions/runs/${{ github.run_id }}|View GitHub Actions logs>\"}}]}" |
| 275 | + -d "$PAYLOAD" |
183 | 276 |
|
184 | 277 | - name: Notify Slack on test failure |
185 | 278 | if: steps.agent.outcome == 'success' && steps.secrets-check.outcome == 'success' && steps.tests.outcome != 'success' |
186 | 279 | run: | |
| 280 | + TASK="${{ github.event.client_payload.task || github.event.client_payload.original_task }}" |
| 281 | + REQUESTER="${{ github.event.client_payload.requester }}" |
| 282 | + RUN_ID="${{ github.run_id }}" |
| 283 | + |
| 284 | + PAYLOAD=$(jq -n \ |
| 285 | + --arg text "❌ AICODE failed: Tests didn't pass" \ |
| 286 | + --arg task "$TASK" \ |
| 287 | + --arg requester "$REQUESTER" \ |
| 288 | + --arg run_id "$RUN_ID" \ |
| 289 | + '{ |
| 290 | + text: $text, |
| 291 | + blocks: [ |
| 292 | + { |
| 293 | + type: "section", |
| 294 | + text: { |
| 295 | + type: "mrkdwn", |
| 296 | + text: ("❌ *AICODE Test Failure*\n\n*Task:* " + $task + "\n*Requested by:* " + $requester + "\n*Issue:* Generated code failed tests\n\nReview the test output and adjust the changes.") |
| 297 | + } |
| 298 | + }, |
| 299 | + { |
| 300 | + type: "section", |
| 301 | + text: { |
| 302 | + type: "mrkdwn", |
| 303 | + text: ("<https://github.com/htilly/SlackONOS/actions/runs/" + $run_id + "|View GitHub Actions logs>") |
| 304 | + } |
| 305 | + } |
| 306 | + ] |
| 307 | + }') |
| 308 | + |
187 | 309 | curl -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \ |
188 | 310 | -H "Content-Type: application/json" \ |
189 | | - -d "{\"text\":\"❌ AICODE failed: Tests didn't pass\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"❌ *AICODE Test Failure*\\n\\n*Task:* ${{ github.event.client_payload.task || github.event.client_payload.original_task }}\\n*Requested by:* ${{ github.event.client_payload.requester }}\\n*Issue:* Generated code failed tests\\n\\nReview the test output and adjust the changes.\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"<https://github.com/htilly/SlackONOS/actions/runs/${{ github.run_id }}|View GitHub Actions logs>\"}}]}" |
| 311 | + -d "$PAYLOAD" |
0 commit comments