<![CDATA[
Automating your deployments saves time and reduces the risk of human error. If you’re hosting on Plesk, you have two solid options for wiring up GitHub Actions: the tried-and-tested rsync over SSH method, or the slicker Plesk built-in Git integration triggered by a webhook. This guide covers both.
Prerequisites
- A Plesk server with SSH access enabled
- A GitHub repository for your project
- Basic familiarity with GitHub Actions YAML syntax
Method 1: rsync over SSH with GitHub Secrets
This is the most flexible method and works regardless of how your Plesk server is configured. It uses rsync to sync your built files directly to a folder on the server over SSH.
Step 1: Generate an SSH Key Pair
On your local machine (or CI environment), generate a dedicated deploy key:
ssh-keygen -t ed25519 -C "github-actions-deploy" -f deploy_key -N ""
This creates two files: deploy_key (private) and deploy_key.pub (public).
Step 2: Add the Public Key to Plesk
- Log in to Plesk and navigate to your subscription.
- Go to Websites & Domains → SSH Access (or your user’s SSH Keys section).
- Paste the contents of
deploy_key.pubinto the authorised keys.
Alternatively, SSH into your server and append it manually:
echo "your-public-key-contents" >> ~/.ssh/authorized_keys
Step 3: Add Secrets to GitHub
In your GitHub repository, go to Settings → Secrets and variables → Actions and add the following secrets:
SSH_PRIVATE_KEY— the contents of yourdeploy_keyfileSSH_HOST— your server’s hostname or IP addressSSH_USER— the SSH username (e.g.plesk-user)DEPLOY_PATH— the absolute path to the deployment folder on the server (e.g./var/www/vhosts/example.com/httpdocs)
Step 4: Create the GitHub Actions Workflow
Create .github/workflows/deploy.yml in your repository:
name: Deploy to Plesk via rsync
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Optional: build step (e.g. npm run build)
- name: Install dependencies and build
run: |
npm ci
npm run build
- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Deploy via rsync
run: |
rsync -avz --delete
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no"
./dist/
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEPLOY_PATH }}
Key rsync flags explained:
-a— archive mode (preserves permissions, timestamps, symlinks)-v— verbose output-z— compress files during transfer--delete— removes files on the server that no longer exist locally
Adjust ./dist/ to match your build output directory (e.g. ./build/, ./public/, or ./ for the whole repo root).
Method 2: Plesk Built-in Git Integration with Webhooks
Plesk has a native Git integration that can pull your repository and optionally run deployment scripts automatically. You trigger it from GitHub Actions using a webhook — no rsync or separate SSH key management required.
Step 1: Configure Git in Plesk
- In Plesk, navigate to your domain and open the Git panel.
- Click Add Repository and paste your GitHub repository URL.
- Choose the branch to track (e.g.
main). - Set the deployment path to your web root (e.g.
/httpdocs). - Optionally, add a deployment script to run after each pull (e.g.
npm ci && npm run build). - For private repositories, follow the on-screen instructions to add Plesk’s public key as a deploy key in your GitHub repository under Settings → Deploy keys.
Step 2: Copy the Plesk Webhook URL
Once the repository is configured in Plesk, you’ll see a webhook URL displayed in the Git panel. It looks something like:
https://your-server.com:8443/modules/git/?action=pull&repository=xxxxxxxxxxxxxxxx
Copy this URL — you’ll add it as a GitHub Secret.
Step 3: Add the Webhook URL to GitHub Secrets
In your GitHub repository, go to Settings → Secrets and variables → Actions and add:
PLESK_WEBHOOK_URL— the full webhook URL copied from Plesk
Step 4: Create the GitHub Actions Workflow
Create .github/workflows/deploy.yml:
name: Deploy to Plesk via Webhook
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Trigger Plesk Git deployment
run: |
curl -s -o /dev/null -w "%{http_code}"
"${{ secrets.PLESK_WEBHOOK_URL }}"
When this workflow runs, it sends a request to Plesk’s webhook endpoint. Plesk then pulls the latest commit from your repository and runs any deployment script you configured.
Optional: Check the Response Code
To make the workflow fail if the webhook returns an error, add a status check:
- name: Trigger Plesk Git deployment
run: |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${{ secrets.PLESK_WEBHOOK_URL }}")
echo "Webhook response: $STATUS"
if [ "$STATUS" -ne 200 ]; then
echo "Deployment webhook failed with status $STATUS"
exit 1
fi
Which Method Should You Use?
| Feature | rsync over SSH | Plesk Webhook |
|---|---|---|
| Build happens in | GitHub Actions runner | Plesk server |
| Setup complexity | Moderate | Low |
| Fine-grained control | High | Medium |
| Requires SSH access | Yes | No |
| Best for | Pre-built static sites, complex pipelines | PHP/WordPress projects, simple deploys |
For most PHP or WordPress-based Plesk projects, the webhook method is the quickest to set up. If you need to run a build step (e.g. compiling assets, bundling JS) before deployment, the rsync method gives you more control over exactly what gets pushed to the server.
Conclusion
Both approaches integrate cleanly with GitHub Actions and keep your credentials safe inside GitHub Secrets. Whether you prefer to push your built artefacts directly via rsync, or let Plesk pull your code via its native Git integration, you now have a repeatable, automated deployment pipeline for your Plesk-hosted projects.
Got questions or a different workflow you prefer? Drop a comment below.
]]>
Leave a Reply
You must be logged in to post a comment.