How to Run a Smoke Test After Deploy in GitHub Actions
A smoke-test job that needs: the deploy polls the live endpoint and fails the run if the release is bad.
Add a job that needs: deploy and curls a health or canary endpoint with retries. If it never returns healthy, the job fails - your signal to roll back.
Poll health after deploy
The smoke job runs only after deploy; the retry loop fails the job if health never comes up.
.github/workflows/deploy.yml
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- run: ./deploy.sh
smoke:
needs: deploy
runs-on: ubuntu-latest
steps:
- run: |
for i in $(seq 1 10); do
code=$(curl -s -o /dev/null -w '%{http_code}' https://app.example.com/healthz)
[ "$code" = "200" ] && exit 0
sleep 6
done
echo "Health check never returned 200" && exit 1Gotchas
- Give the new release time to come up - poll with backoff rather than a single immediate request.
- Hit a real readiness signal (
/healthz, a canary route), not just the load balancer, which may answer before pods are ready. - Pair the smoke test with an automatic rollback step (
if: failure()) so a bad release does not stay live.
Related guides
How to Deploy to Kubernetes from GitHub ActionsDeploy to Kubernetes from GitHub Actions - configure kubectl with a secret kubeconfig (or cloud OIDC), set th…
How to Run a Smoke Test After Deploy in GitLab CIRun a post-deploy smoke test in GitLab CI as a stage after deploy that polls a health endpoint and fails the…