How to Run a Synthetic Monitoring Check After Deploy in GitHub Actions
Synthetic checks probe your release from outside your network, so triggering one on deploy verifies the path a real user takes, not just the internal health endpoint.
Call your synthetics provider API to run the relevant test on demand, poll the result, and fail the release if the synthetic check reports a failure.
Steps
- Trigger the synthetic test via the provider API with the test ID.
- Poll the result endpoint until the run finishes.
- Fail the gate if the reported status is not passed.
Workflow
.github/workflows/ci.yml
- name: Trigger synthetic check
env:
DD_API_KEY: ${{ secrets.DD_API_KEY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
run: |
RES=$(curl -sf -X POST "https://api.datadoghq.com/api/v1/synthetics/tests/trigger" \
-H "DD-API-KEY: $DD_API_KEY" -H "DD-APPLICATION-KEY: $DD_APP_KEY" \
-H "Content-Type: application/json" \
-d '{"tests":[{"public_id":"abc-def-ghi"}]}')
echo "$RES" | jq .
# Poll the batch result, then assert status == passedGotchas
- The trigger returns a batch id; you must poll the batch for the final pass/fail, not read the trigger response.
- Synthetics run from provider locations; a location outage can look like a release failure, so check the reason before rolling back.
Related guides
How to Alert on a Verification Failure in GitHub ActionsSend a Slack alert from GitHub Actions when post-deploy verification fails, so on-call is notified with the r…
How to Run a Smoke Test After Deploy in GitHub ActionsRun a post-deploy smoke test in GitHub Actions that hits critical endpoints and fails the job on a non-2xx re…