Overview

Plesk features Git integration, which allows to you automatically deploy your code repositories direct to your website. This can be used for a specific directory, for example a WordPress theme or plugin. This article will step you through the process to configure Git integration using a GitHub based repository.

We also have guides available for GitLab and BitBucket.

Instructions

Warning

Using a Git based deployment method will delete any existing files within the directory selected. Please ensure you take a backup first before proceeding.

  1. Login to Plesk or the Conetix Control Panel.
  2. Select the website you wish to use Git based deployment with.
  3. Select the Git option:
    automatic git deployments via github to plesk based hosting
  4. In a new window or tab, Login to GitHub, and select the repository you wish to deploy. In this example, we’re going to configure conetix/conetix-demo-theme:
    automatic git deployments via github to plesk based hosting
  5. Select Code on the right hand side, then choose “Use SSH”:
    automatic git deployments via github to plesk based hosting
  6. Copy the SSH based URL:
    automatic git deployments via github to plesk based hosting
  7. Return to the Plesk config and paste the URL into the dialog:
    automatic git deployments via github to plesk based hosting
    Do not hit OK yet.
  8. On the right hand side within Plesk, click on the httpdocs folder:
    automatic git deployments via github to plesk based hosting
  9. This will open up a dialog. If this is a WordPress theme or similar, select the path (eg /wp-content/themes) and create a new folder or select a previous directory if replacing an existing theme”
    automatic git deployments via github to plesk based hosting
    All files will be replaced if you select an existing folder.
  10. Double check that the desired folder has now been set:
    automatic git deployments via github to plesk based hosting
  11. Take a copy the SSH public key:
    automatic git deployments via github to plesk based hosting
    Do not click on OK yet.
  12. Then, go back to the browser tab with GitHub open.
  13. At the top, select Settings:
    automatic git deployments via github to plesk based hosting
  14. Then, select Deploy Keys:
    automatic git deployments via github to plesk based hosting
  15. Click Add deploy key on the right, then enter a name for the key and paste the SSH public key in, then click Add key:
    automatic git deployments via github to plesk based hosting
  16. If you haven’t made a recent change within GitHub, it will ask for your password as a confirmation of the action:
    automatic git deployments via github to plesk based hosting
  17. You should then see a confirmation that the key has been added:
    automatic git deployments via github to plesk based hosting
  18. Return to the Plesk browser window, triple check you have the correct directory selected and click on OK. This will trigger the deployment and you should see something similar to the following:
    automatic git deployments via github to plesk based hosting
  19. After the initial deployment, you should then see a summary screen with the Git configuration. Select Repository Settings:
    automatic git deployments via github to plesk based hosting
  20. Take a copy of the webhook URL:
    automatic git deployments via github to plesk based hosting
  21. Return to the browser window with GitHub then select Settings -> Webhooks and select Add webhook:
    automatic git deployments via github to plesk based hosting
  22. Add the URL (to the Payload URL field) and leave all other settings as defaults:
    automatic git deployments via github to plesk based hosting
  23. Click on Add webhook to save. This will automatically trigger a test of the webhook and deploy the code as requested.
  24. To confirm this worked, you can click on Edit for the webhook, then view the recent deliveries at the bottom of the screen:
    automatic git deployments via github to plesk based hosting
  25. Return to the Plesk browser window and simply cancel the dialog to edit the Repository Settings (we just needed open to copy the webhook).
  26. To confirm the files are deployed, you can use the Plesk File Manager to browse to the file location and confirm it pulled down the code changes:
    automatic git deployments via github to plesk based hosting

Information

With Git configured via the webhook, any push to GitHub master branch will now automatically update the files deployed on your website.

Was this article helpful?

Related Articles