Skip to content

Plesk Git-based deployment — automatic deploy on push, build hooks, deploy keys

Wire a customer's Plesk subscription to a Git repo so every push to main deploys, run a build hook, and use a per-subscription deploy key without giving Plesk write access to your tree.

The customer ships a WordPress theme from a GitHub repo and asked for “automatic deploys.” You FTPed it once and forgot. Two weeks later the customer asks why their last commit isn’t on the site. The answer is “because we deployed it manually and nobody told us about the commit,” which is the wrong answer. Plesk has a Git extension that does this properly — every push to a chosen branch triggers a pull on the panel, runs a configurable build hook, and reports the result back in the panel UI. It is one of the under-used features of the panel and it removes the FTP step entirely. Setting it up takes ten minutes per subscription if you know the four pieces; an hour if you don’t.

What’s happening

The Plesk Git extension installs a small daemon plus a webhook endpoint per subscription. When you connect a repo, Plesk generates a unique deploy key (or you upload one you already control) and gives you a webhook URL. You drop the deploy key into the repo as a read-only deploy key, you drop the webhook URL into GitHub/GitLab/Bitbucket as a push webhook, and from then on every push to the chosen branch triggers Plesk to git pull into the document root (or a build directory) and then run a shell hook you wrote. The hook is the build step: composer install, npm ci + npm run build, gulp, anything. Plesk runs the hook as the subscription’s system user, captures stdout/stderr, and shows the last twenty deploys in the panel with the commit SHA. Two things go wrong if you skip the build hook: the customer pushes raw source (untranspiled, unbuilt assets) and the site breaks; or you accept the default which git pulls into the document root including .git/ and .env, both of which become world-readable until you fix the perms.

How to verify

The Git extension should be installed and the daemon running on the panel node:

plesk bin extension --list | grep -i git
# git: Git
systemctl status plesk-git-deploy 2>/dev/null || plesk ext git --info

A subscription with Git wired up exposes a webhook URL — find it via the CLI:

plesk ext git --list --domain example.com
plesk ext git --info --domain example.com --repository main

After the first push, the deploy log shows the last run:

plesk ext git --logs --domain example.com --repository main | tail -50

The repo’s .git directory must NOT be under the document root after deploy. If it is, the site exposes .git/config publicly:

sudo -u customer-example ls -la /var/www/vhosts/example.com/httpdocs/ | head -5
# .git should not be in the document root unless you understand the consequences
curl -sS -o /dev/null -w '%{http_code}\n' https://example.com/.git/config
# Expect 403; anything else is a leak

The fix

The end-to-end wire-up is five steps: install the Git extension if it isn’t already, connect the repo from the CLI, drop the deploy key into the source forge, drop the webhook URL into the source forge, and write the build hook. The example below assumes the customer subscription is example.com, the repo is git@github.com:acme/site.git, and the deploy branch is main.

1. Install the Git extension (idempotent)

plesk installer --select-release-current --install-component git
plesk ext git --info

2. Connect the repo from the Plesk CLI

The Plesk Git extension supports two modes: pull mode (Plesk pulls from a remote repo on every push via webhook — what most teams want) and push mode (the panel hosts the repo itself and the developer pushes into Plesk — useful when there’s no GitHub).

Pull mode against a GitHub repo:

plesk ext git --create \
  --domain example.com \
  --repository main \
  --type remote \
  --remote-url "git@github.com:acme/site.git" \
  --target-directory "httpdocs" \
  --branch main \
  --auto-deploy true

Plesk generates a deploy key on the subscription. Print it:

plesk ext git --info \
  --domain example.com \
  --repository main | grep -A 30 "Public key"

The output includes the SSH public key (ssh-rsa AAA...) and the webhook URL (https://panel.example.com:8443/modules/git/public/web-hook.php?...).

3. Add the deploy key to GitHub (read-only)

In the GitHub repo: Settings → Deploy keys → Add deploy key. Paste the public key Plesk printed. Do not tick “Allow write access” — Plesk only needs to pull.

4. Add the webhook to GitHub

Settings → Webhooks → Add webhook. Paste the webhook URL Plesk printed. Content type: application/json. Events: just push (or push + Pull request if you want preview environments later). Save.

5. Write the build hook

Plesk lets you run a script after every successful pull. It runs as the subscription’s system user, in the target directory. Write it via the CLI:

plesk ext git --update \
  --domain example.com \
  --repository main \
  --actions "composer install --no-dev --optimize-autoloader && npm ci && npm run build"

For a WordPress site with a custom theme:

plesk ext git --update \
  --domain example.com \
  --repository main \
  --actions "composer install --no-dev --no-interaction \
            && cd wp-content/themes/acme \
            && npm ci \
            && npm run build \
            && find wp-content -type d -exec chmod 755 {} + \
            && find wp-content -type f -exec chmod 644 {} +"

For a static Hugo site that builds to public/ and is then served from httpdocs/:

plesk ext git --update \
  --domain example.com \
  --repository main \
  --target-directory "private/src" \
  --actions "cd /var/www/vhosts/example.com/private/src \
            && hugo --minify \
            && rsync -a --delete public/ /var/www/vhosts/example.com/httpdocs/"

--target-directory is critical here: pulling into a private directory and then rsyncing the built output into httpdocs/ keeps .git/ out of the document root automatically.

6. First push and verification

Push to the repo and watch the deploy log:

git push origin main

# On the Plesk node:
plesk ext git --logs --domain example.com --repository main | tail -20

The log entries are timestamped, include the commit SHA, the build hook’s exit code, and the last 50 lines of build output. A failed build hook does not roll back the pull, but it does flag the deploy as failed in the panel UI, which is enough for the customer to see something went wrong.

Per-subscription SSH access for advanced flows

When the customer is technical and wants to run their own deploy commands beyond the build hook, give the subscription’s system user SSH access (chroot or full shell) and they can git clone and run a custom CI agent themselves. Plan template controls whether SSH is available on a subscription:

plesk bin subscription --update example.com -ssh true -ssh-jail true

A chrooted shell keeps the customer’s deploys contained to their webspace tree. Pair it with composer + npm aliases in /etc/profile.d/ if you want everyone’s hook syntax to match.

By default the Plesk webhook endpoint accepts any POST to the URL. Anyone who sees the URL can trigger a deploy. Plesk supports HMAC verification — set a webhook secret in GitHub and pass the same secret to Plesk:

plesk ext git --update \
  --domain example.com \
  --repository main \
  --webhook-secret "$(openssl rand -hex 32)"

GitHub: Settings → Webhooks → edit webhook → Secret → paste the same value. Plesk rejects pushes without a valid X-Hub-Signature-256 after this is set.

Once the four wires are in place — deploy key, webhook, build hook, signature — every push to the chosen branch deploys in seconds, the FTP step is gone, and the customer can see the deploy result from the panel without asking you.

Run this Git-deploy workflow on Stack Harbor’s Cloud Compute with deploy alerting and rollback runbooks handled by our deployment management team — or pair us with your CI if you’d like to push from GitHub Actions or GitLab CI instead of relying on the panel webhook alone.