Vishal Tyagi
← Writing
·concluded

Webhook Deploys Without CI/CD

Automatic git-pull deployments on shared hosting: GitHub webhook → Laravel endpoint → queued RunDeployment job, and when that pattern is (and is not) appropriate.

Shared hosting rarely offers a clean CI push over SSH. A workable alternative: trigger deploy from inside the server.

Flow

GitHub push
  → POST /api/webhook (verify X-Hub-Signature-256)
    → dispatch RunDeployment to queue
      → [Node queue supervisor](/projects/laravel-queue-shared-hosting) runs:
          git fetch / reset / pull
          composer install
          migrate + optimize:clear

Used on the school CMS.

Why queue the deploy

Synchronous git pull + composer + migrate in the webhook handler risks PHP timeouts and GitHub retries (duplicate concurrent deploys). Returning 200 and running the job in the background avoids that.

Failure modes

  • Concurrent deploys — use a dedicated queue with a single worker
  • Migrate fails after pull — code ahead of schema; rollback is manual
  • Composer not on PATH — resolve full binary via env

Fit

Good for small institutional sites where a brief deploy window is fine. Not for multi-server, hard zero-downtime, or catastrophic-migrate domains — use real CI/CD or blue-green there.