Notify Investigator #762
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Notify Investigator | |
| # Centralized watcher for Investigator: `workflow_run`'s own computed | |
| # conclusion catches a run that fails overall even when one job's own | |
| # `if: failure()` wouldn't (e.g. a late Launchable collection error). | |
| # Add a workflow to `workflows:` below to watch it -- nothing else to touch. | |
| on: | |
| workflow_run: | |
| workflows: | |
| - "E2E tests Matrix" | |
| - "PSMDB GSSAPI E2E Tests Matrix" | |
| - "Helm tests" | |
| - "PMM Integration Tests" | |
| - "Nightly E2E tests Matrix (remote PMM Server)" | |
| types: [completed] | |
| jobs: | |
| notify-investigator: | |
| name: Fire Investigator routine | |
| runs-on: ubuntu-latest | |
| # Nightly E2E tests Matrix has no 'schedule' event (Jenkins dispatches it | |
| # via workflow_dispatch), so any failed completed run notifies; the other | |
| # four only notify on their own unattended cron run, not a human's manual | |
| # re-run. head_branch is checked against the repo's actual default branch. | |
| if: > | |
| github.event.workflow_run.conclusion == 'failure' && | |
| github.event.workflow_run.head_branch == github.event.repository.default_branch && | |
| ( | |
| github.event.workflow_run.event == 'schedule' || | |
| github.event.workflow_run.name == 'Nightly E2E tests Matrix (remote PMM Server)' | |
| ) | |
| steps: | |
| - name: Fire Investigator routine | |
| env: | |
| # Update this if Investigator's routine is ever recreated. | |
| ROUTINE_ID: trig_01FhHBdz2yBibyVEfnG5gbQz | |
| ROUTINE_TOKEN: ${{ secrets.INVESTIGATOR_ROUTINE_TOKEN }} | |
| WORKFLOW_NAME: ${{ github.event.workflow_run.name }} | |
| RUN_URL: ${{ github.event.workflow_run.html_url }} | |
| run: | | |
| if [ -z "$ROUTINE_TOKEN" ]; then | |
| echo "::error::INVESTIGATOR_ROUTINE_TOKEN is not set -- Investigator was not notified of this failure." >&2 | |
| exit 1 | |
| fi | |
| curl -fsS -X POST "https://api.anthropic.com/v1/claude_code/routines/${ROUTINE_ID}/fire" \ | |
| -H "Authorization: Bearer ${ROUTINE_TOKEN}" \ | |
| -H "anthropic-version: 2023-06-01" \ | |
| -H "anthropic-beta: experimental-cc-routine-2026-04-01" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"text\": \"Workflow '${WORKFLOW_NAME}' failed. Run: ${RUN_URL}\"}" |