Skip to content

GitHub repository_dispatch

Goal: when DownBad confirms an incident, a GitHub Actions workflow in your repository runs with DownBad’s diagnosis of it, and runs again when the incident recovers.

GitHub Actions runs workflows, files in .github/workflows/ that say what to do when something happens in a repository. A repository_dispatch event is one that something outside GitHub sends through GitHub’s API, here DownBad. GitHub documents it under Create a repository dispatch event and Events that trigger workflows › repository_dispatch.

You need a paid DownBad plan and a GitHub repository you can push to.

  1. Make a token that can send the event. In GitHub, go to Settings › Developer settings › Personal access tokens. A fine-grained token needs only this repository and Contents: Read and write; a classic token needs the repo scope. GitHub’s guide: Managing your personal access tokens.

  2. Add a workflow that runs on DownBad’s events. Commit a file such as .github/workflows/downbad.yml to the repository’s default branch:

    name: DownBad incident
    on:
    repository_dispatch:
    types: [downbad.incident.confirmed, downbad.incident.recovered]
    jobs:
    respond:
    runs-on: ubuntu-latest
    steps:
    - name: Show what DownBad found
    env:
    BRIEF: ${{ github.event.client_payload.brief }}
    INCIDENT: ${{ github.event.client_payload.incidentId }}
    EVENT: ${{ github.event.action }}
    run: |
    echo "Incident $INCIDENT: $EVENT"
    echo "$BRIEF"

    github.event.action is the event type DownBad sent, and github.event.client_payload is the payload. Pass payload values to a script through env: as above, never by pasting ${{ }} into a run: line, since dossier.untrustedEvidence holds text the monitored site wrote.

  3. Add it in DownBad. Go to Settings › Alerts, press Add webhook and paste either the repository’s page, such as https://github.com/acme/web-app, or its dispatches address, https://api.github.com/repos/acme/web-app/dispatches. DownBad recognizes it as GitHub repository_dispatch and asks for:

    • GitHub token: from step 1.
    The new webhook form with a GitHub repository page pasted, recognised as GitHub repository_dispatch, and the GitHub token filled in as dots.
  4. Save. DownBad makes a signing secret for the channel and shows it once. GitHub doesn’t pass request headers on to the workflow, so the workflow never sees the X-DownBad-Signature header: keep the secret only if something else reads the requests, and otherwise press Done.

  5. Press Test now on the saved channel. DownBad sends the event type downbad.test, which the workflow above ignores. Add downbad.test to types: to see a test run.

  6. Add the channel to the notification profiles of the monitors the workflow should hear about.

DownBad never shows the token or the signing secret again once saved. To keep the token when you edit the channel, leave its field empty. To get a new signing secret, press Rotate signing secret on the channel.

The test answers GitHub accepted the repository_dispatch event downbad.test. For a real incident:

  • When DownBad confirms the incident, it sends downbad.incident.confirmed once.
  • When the incident closes, it sends downbad.incident.recovered once.
  • Nothing else is sent: not each failing check, not escalation reminders, and not quiet-hours summaries. Quiet hours and maintenance hold it the same way they hold your other alerts.

The client_payload is described in Agent Webhook › The payload. Failed deliveries are retried like any webhook’s: see Webhooks › What happens when delivery fails.

The delivery fails with HTTP 404, “Not Found”. GitHub answers 404 when the token can’t see the repository: the owner or name is misspelled, or the token wasn’t given this repository. Check the URL, and the token’s Repository access.

The delivery fails with HTTP 401 or 403. The token expired, was revoked, or lacks Contents: Read and write (the repo scope for a classic token). Make a new one and paste it into the channel.

The delivery is accepted but no workflow runs. GitHub runs a repository_dispatch workflow only from the default branch, and only for an event type in its types: list. Check the file is on the default branch and lists downbad.incident.confirmed.

Alerts stopped and the bell says the webhook was switched off. Ten deliveries in a row failed. Fix the cause above, then press Test now to switch the channel back on.