With a token, Cipi sets up the webhook on GitHub, GitLab, Bitbucket and Azure DevOps by itself. This guide shows what happens behind it, and how to wire Gitea or Forgejo by hand.
Key ideas, in plain words#
| Term | Meaning |
|---|---|
| Webhook | An HTTP call your Git provider makes on each push |
| Signature | A hash of the request made with a shared secret, proving it came from your provider |
| Trigger | A small file the webhook leaves; a cron starts the deploy from it |
You push to the app's deploy branch. Other branches are ignored.
Your Git provider sends a signed POST to the app's webhook URL.
Cipi checks the signature (only someone with the secret can trigger a deploy) and the branch.
It writes a small trigger file and answers immediately, so the provider never sees a timeout, however long the build.
Within a minute a cron job picks up the trigger and deploys as the app's own user, with zero downtime.
The request never runs the deploy itself: it verifies the push and drops a trigger. A cron picks it up and deploys with zero downtime. A slow build can't time out a webhook, and a forged request can't start anything.
1. Get the URL and token#
sudo cipi deploy shop --webhook
2. Add the webhook#
| Provider | Payload URL | Secret / token | Events |
|---|---|---|---|
| GitHub | https://shop.example.com/cipi/webhook | Secret = token (HMAC-SHA256), content type JSON | Just the push event |
| GitLab | same | Secret token | Push events |
| Bitbucket Cloud | same | Secret (HMAC) | Repository push |
| Gitea / Forgejo | same | Secret (HMAC) | Push events |
Only pushes to the app's branch (CIPI_DEPLOY_BRANCH) deploy; others answer skipped. GitHub's ping answers pong.
3. Push and watch#
git push origin main
sudo cipi deploy shop --status # running, queued or idle
sudo cipi deploy shop --log4. Know who pushed#
Each trigger records what the push claimed (provider, pusher, commit, delivery ID, IP) in the deploy audit. It's recorded as a claim, not a fact: the ledger is hash-chained, so it can't be quietly edited later.
sudo cipi deploy shop --audit
Rotate the secret#
sudo cipi app webhook recreate shop --rotate-secret
Need tests before deploying? Turn the webhook off and use a pipeline.
Troubleshooting#
| Problem | Fix |
|---|---|
| Provider shows 401/403 | Secret or token mismatch: copy it again from cipi deploy shop --webhook |
| 200 but no deploy | Push to a branch that isn't the deploy branch |
| Deploy starts a minute later | Normal: the cron picks the trigger up within a minute |
| Nothing at all reaches the server | Webhook URL wrong, or the app is behind Zero Trust without a bypass rule for /cipi/webhook |
Questions
Does a push to another branch deploy?
No. Only pushes to the app's deploy branch (CIPI_DEPLOY_BRANCH) trigger a deploy; others are acknowledged and ignored.
What if two pushes arrive at once?
Deploys are serialized per app: the second waits, then deploys the newest commit.
Is the webhook safe on a public URL?
Yes. Every request must carry a valid signature or token; anything else is refused before any work starts.
What if a step fails?
Read the troubleshooting table above first. Then check the matching docs page, open a GitHub issue, or ask in the community. Most commands print the fix when they refuse something.
Do I need the web panel for this?
No. Every step works from the CLI. The optional web panel shows the same things in a browser.
Can I run these commands from my laptop?
Many of them, through cipi-cli and the API, with a scoped token. Otherwise ssh cipi@your-server and use sudo cipi ….
Will this affect other apps on the server?
No, unless the step says it's server-wide (installing a PHP version, firewall, Cloudflare tunnel). Each app has its own user, PHP pool, database and Valkey.