Interview Prep/Python for DevOps/Testing, CI/CD, packaging & services

You need a webhook receiver for GitHub that triggers deployments. Design it.

AdvancedScenarioTesting, CI/CD, packaging & services
Answer

Situation read → Public endpoint that can deploy to production.

What I'd do →

  1. FastAPI or Flask endpoint verifying X-Hub-Signature-256 with HMAC-SHA256 over the raw body and hmac.compare_digest.
  2. Filter events (X-GitHub-Event: push on refs/heads/main, or release published).
  3. Deduplicate on X-GitHub-Delivery; enqueue a job and return 202 within GitHub's 10-second timeout.
  4. A worker performs the deploy idempotently and reports status back (commit status or deployment API).
  5. Restrict ingress to GitHub's published hook IP ranges (from api.github.com/meta) as an extra layer.

Why → Signature, dedupe, and async processing are the three properties a deploy webhook needs.

Interview tip → Ask whether a pull-based model (Argo CD) removes the need for an inbound webhook.

All Python for DevOps questions Roadmap: Python for automation

More on Testing, CI/CD, packaging & services