How to Send a Webhook on Deploy
A deploy webhook POSTs the version and environment to downstream systems once a deploy succeeds.
Add a final step, gated on success, that POSTs a small JSON body to the receiver with the version, environment, and commit SHA.
Steps
- Add a final step gated on
if: success(). - POST a JSON body with version, environment, and SHA.
- Sign the body so the receiver can verify it (see the HMAC guide).
Workflow
.github/workflows/deploy.yml
steps:
- run: ./deploy.sh
- name: Notify on deploy
if: success()
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{"env":"production","sha":"${{ github.sha }}","version":"${{ github.ref_name }}"}' \
${{ secrets.DEPLOY_WEBHOOK_URL }}Gotchas
- Gate on success so a failed deploy does not announce itself as shipped.
- Sign the payload so the receiver can verify it rather than trusting the URL alone.
Related guides
How to Send an Outbound Webhook From a WorkflowSend an outbound webhook from a CI workflow with a curl POST, failing the step on a non-2xx response so a dro…
How to Drive GitOps With WebhooksDrive a GitOps flow with webhooks by having a build POST a repository_dispatch that updates a manifest and le…