Automatic Git Deployments from GitHub

Automatic Git Deployments from GitHub Print

  • 0

Push code to GitHub and see it go live on your website automatically — no FTP, no manual uploads. WebOps Hosting includes built-in Git integration through the Plesk control panel, letting you deploy directly from GitHub (or GitLab, Bitbucket, and other Git providers).

This guide walks you through connecting a GitHub repository to your website so that every push to your main branch triggers an automatic deployment.

What You''ll Need

  • A WebOps Hosting account with Plesk access
  • A GitHub account with a repository containing your website code
  • Basic familiarity with Git (commits, pushes, branches)

How It Works

The setup creates a secure, one-way connection between GitHub and your hosting account:

  1. You push code to your GitHub repository
  2. GitHub notifies Plesk via a webhook
  3. Plesk pulls the code and deploys it to your website directory

Authentication uses SSH deploy keys — a secure key pair that gives Plesk read-only access to your repository. No passwords are stored or transmitted.

Step 1: Get Your Repository''s SSH URL

In your GitHub repository, click the green Code button near the top right. Select the SSH tab (not HTTPS) and copy the URL. It will look like:

git@github.com:username/my-website.git

If you don''t see an SSH option, you may need to set up SSH keys on your GitHub account first.

Step 2: Create a Git Repository in Plesk

Log in to your Plesk control panel and navigate to your domain. Scroll down to the Dev Tools section and click Git.

Plesk Git Repositories page with Add Repository button

Click Add Repository to open the setup dialog.

Step 3: Configure the Repository Connection

In the "Create repository" dialog:

  1. Under Code location, select Remote repository (this should be selected by default)
  2. Paste your SSH URL into the Repository URL field
  3. Plesk will automatically generate an SSH deploy key and display it below the URL field

Plesk Create Repository dialog showing SSH URL, deploy key, and deployment settings

Copy the entire SSH public key content — you''ll need it in the next step. Don''t click Create yet.

While you''re here, review the deployment settings at the bottom of the dialog:

  • Deployment mode: Set to Automatic for instant deploys on every push. Choose Manual if you prefer to trigger deploys yourself from Plesk.
  • Server path: Defaults to /httpdocs (your website root). Change this if you want to deploy to a subdirectory — for example, /httpdocs/app for a specific application folder.

Step 4: Add the Deploy Key to GitHub

In a new browser tab, go to your GitHub repository:

  1. Click Settings (you need admin access to the repository)
  2. In the left sidebar, click Deploy keys
  3. Click Add deploy key
  4. Give it a descriptive title (e.g., "WebOps Hosting - Production")
  5. Paste the SSH public key you copied from Plesk
  6. Leave "Allow write access" unchecked — Plesk only needs to read your code
  7. Click Add key

Step 5: Complete the Repository Setup in Plesk

Go back to the Plesk tab and click Create. Plesk will connect to GitHub and pull your code for the first time. This initial deployment may take a moment depending on the size of your repository.

Once complete, you''ll see a confirmation screen showing the deployment status and the repository details.

Step 6: Set Up the Webhook for Automatic Deploys

After the repository is created, click on the repository name to open Repository Settings. You''ll see a Webhook URL — copy it.

Now set up the webhook in GitHub:

  1. In your GitHub repository, go to Settings > Webhooks
  2. Click Add webhook
  3. Paste the webhook URL into the Payload URL field
  4. Leave Content type as application/x-www-form-urlencoded
  5. Under "Which events would you like to trigger this webhook?" leave Just the push event selected
  6. Click Add webhook

GitHub will send a test ping immediately. You can verify it worked by clicking into the webhook and checking Recent Deliveries — you should see a successful delivery with a green checkmark.

Step 7: Test Your Deployment

Make a small change to a file in your repository, commit it, and push to your main branch. Within seconds, Plesk will pull the update and deploy it to your website.

You can monitor deployments in Plesk under the Git section of your domain — each deploy shows its status, commit hash, and timestamp.

Deploying a Specific Branch

By default, Plesk deploys the main (or master) branch. To deploy from a different branch:

  1. Go to your domain in Plesk and click Git
  2. Click on the repository name to open settings
  3. Change the Branch field to your preferred branch name

This is useful for staging environments — for example, deploy main to your production site and develop to a staging subdomain.

Post-Deployment Actions

Need to run commands after each deploy? When creating or editing a repository, check Enable additional deployment actions and enter shell commands. Common examples:

  • npm install && npm run build — Install dependencies and build a frontend project
  • composer install --no-dev — Install PHP dependencies
  • python3 -m pip install -r requirements.txt — Install Python dependencies

Frequently Asked Questions

Will this delete my existing files?

Yes — Git deployment replaces the contents of the target directory with the repository contents. Always back up your existing files before connecting a Git repository. If your website has user-uploaded content (like images in a /uploads folder), make sure those paths are included in your repository or stored outside the deployment directory.

Can I use this with WordPress?

Yes, but with care. You can deploy a custom theme or plugin from GitHub to a specific subdirectory (e.g., /httpdocs/wp-content/themes/my-theme). Avoid deploying to the WordPress root directory, as it will overwrite WordPress core files.

Can I deploy from GitLab or Bitbucket instead of GitHub?

Absolutely. The process is identical — Plesk supports any Git provider that offers SSH access and webhooks. Just use the SSH clone URL from your GitLab or Bitbucket repository.

What happens if a deploy fails?

Plesk will show the error in the Git section of your domain. Common issues include permission errors (check your deploy key), branch name mismatches, or syntax errors in post-deployment scripts. Your previous deployment remains in place until a successful deploy replaces it.

Can I set up separate production and staging deployments?

Yes. Create a subdomain (e.g., staging.yourdomain.com) and set up a second Git repository pointing to a different branch. This gives you a safe environment to test changes before deploying to production.

I''m not a developer — can you set this up for me?

Of course! Our Content Operations team can configure Git deployment for your website. Just submit a support ticket with your repository URL and we''ll handle the rest.

Questions? Contact us at support [at] webops [dot] host or submit a support ticket. Our team is available 9am-5pm, 7 days a week (24/7 for emergencies).


Was this answer helpful?

« Back