How to Run a Smoke Test After Deploy in GitHub Actions
A smoke test is a small set of requests against the just-deployed environment that must all pass before the release is trusted.
Add a verify job that runs after deploy via needs:, sends a few requests to the deployed URL, and exits non-zero on any failure so the run is marked failed.
Steps
- Add a
verifyjob withneeds: deploy. - Hit each critical path with
curl --fail --show-error. - Return non-zero on the first failed check so the job fails.
- Gate promotion (or trigger rollback) on this job's result.
Workflow
.github/workflows/ci.yml
jobs:
verify:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Smoke test critical paths
env:
BASE: ${{ vars.DEPLOY_URL }}
run: |
set -euo pipefail
curl --fail --show-error --silent "$BASE/healthz"
curl --fail --show-error --silent "$BASE/api/status"
curl --fail --show-error --silent -o /dev/null "$BASE/"Gotchas
curl --failreturns exit 22 on HTTP >= 400, which fails the step; without it curl exits 0 on a 500.- Smoke tests should be fast and read-only; save deep flows for the e2e job.
- Pair this job with automated rollback so a failed smoke test reverts the release, not just reports it.
Related guides
How to Poll a Health Check Until It Returns 200 in GitHub ActionsPoll a health check endpoint after deploy in GitHub Actions, retrying curl until it returns 200 or a timeout…
How to Automatically Roll Back on a Failed Verification in GitHub ActionsAutomatically roll back a release in GitHub Actions when post-deploy verification fails, using a job that run…