Skip to content

Git Deploy

The Git Deploy extension deploys websites automatically from a Git repository (GitHub, GitLab, or a self-hosted Gitea instance) — via git pull, with webhook auto-deploy on every push, signature verification, pre-deploy commands, and a rollback to an earlier commit. It's installed as an opt-in extension via the marketplace.

Installation & enabling

  1. Enable the extension (marketplace) — the agent ensures git and rsync are present on the affected servers.
  2. Package permission — in the package, the admin sets Allow Git Deploy (perm_git_deploy) to control whether a customer can deploy their own websites from external Git repositories — manually or automatically via webhook.

Connecting a repository

  1. On the Git Deploy page, add a repository: repository URL (HTTPS with a .git suffix only), branch, and target website. No provider is selected separately; GitHub, GitLab, or Gitea is determined from the URL and the webhook signature.
  2. For private repositories, an optional access token can be stored.
  3. Optionally set pre-deploy commands (e.g. composer install, npm run build) — on every deployment they run after the files have been copied into the website's web directory.

Deploying

  • Manual — click Deploy in the repository overview.
  • Automatic via webhook — the page shows the webhook URL and a secret to configure in the provider (GitHub/GitLab/Gitea). Incoming webhooks from GitHub and Gitea are verified via HMAC signature, GitLab webhooks via token comparison; only pushes to the configured branch trigger a deployment, all others are ignored.

Every deployment is logged: commit, timestamp, status and the full log output are available under History. The files are copied into the website's web directory (rsync --delete).

Behaviour when a deployment fails:

  • If cloning, fetching, or resetting fails, the web directory is not touched; the live site stays unchanged.
  • Before every sync, the panel saves the current web directory to a snapshot directory git/.snapshots/<domain> in the customer's home, outside the served web root. Only one deployment per repository runs at a time; a second run waits. If the rsync or a pre-deploy command then fails, the snapshot is copied back. The deployment ends as failed, and the log contains rolled back to the previous web root state.
  • If the restore also fails, the log contains rollback failed. The site then needs a manual check.
  • Uploads, storage/, .env, and .git are never deleted or overwritten during sync or restore.
  • The snapshot takes additional disk space roughly the size of the deployed code (excluding uploads and storage). It is overwritten by the next deployment and until then counts against the customer's disk quota.
  • Pre-deploy commands are limited to 300 seconds each. The agent stops a longer-running command, and the snapshot is restored.
  • Restoring covers only the web root. Side effects outside it, such as database migrations or cache files outside the web root, are not rolled back.

Rollback

From the deployment history, you can roll back to an earlier successful commit. The rollback runs git checkout in the work tree and then syncs with the same protection as a deployment. If the commit is no longer present in the work tree, the checkout fails without changing the live site.

Security model

  • Deployments run as the website's own Linux user — no root privileges needed.
  • Each site has its own webhook secret.
  • Private repositories are connected with an access token (stored encrypted). There is no deploy key.
  • The runtime dependencies (git, rsync) are only installed on servers where the extension is enabled.
  • Every authorization decision re-verifies against the real panel API, never against locally decoded JWT claims alone. The extension is also reachable through the deliberately unauthenticated webhook proxy (/api/v1/ext-webhook/git-deploy/*path, meant for GitHub/GitLab-style delivery) — before any privileged action it calls the real panel's /api/v1/my/permissions, which verifies the signature, and only then relies on the locally decoded claims.

Not yet included

  • Multi-branch deployments (e.g. automatic staging per feature branch).
  • Provider selection and SSH deploy keys are not planned. Access goes through HTTPS with an access token.
  • Atomic directory switch (symlink releases): the sync writes directly into the web directory; the snapshot only prevents a half-synced state.
  • Build containers — pre-deploy commands run directly as the site user, not in an isolated build environment.