How to Trigger a Workflow on Deployment Status in GitHub Actions
The deployment_status event fires when a deployment reports a new state, letting you run smoke tests only after a successful deploy.
Add on.deployment_status, then gate on github.event.deployment_status.state == 'success'. Read the target URL from the payload to test the live environment.
Steps
- Add
deployment_status:underon. - Gate on
github.event.deployment_status.state == 'success'. - Read
deployment_status.target_urlto run smoke tests.
Workflow
.github/workflows/smoke.yml
on:
deployment_status:
jobs:
smoke:
if: github.event.deployment_status.state == 'success'
runs-on: ubuntu-latest
steps:
- run: curl --fail "${{ github.event.deployment_status.target_url }}/health"Gotchas
- State can be success, failure, error, inactive, or pending; filter for the ones you handle.
- This event depends on something creating deployments (often a deploy action or the Deployments API).
Related guides
How to Trigger a Workflow After Another Workflow in GitHub ActionsRun a GitHub Actions workflow after another one finishes with the workflow_run event, filtering on the source…
How to Audit Environment Deployments in GitHub ActionsReview the GitHub Actions deployment history for an environment with the gh CLI, listing who deployed what an…