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 GitLab based repository.
- Login to Plesk or the Conetix Control Panel.
- Select the website you wish to use Git based deployment with.
- Select the Git option:
- In a new window or tab, Login to GitLab, and select the repository you wish to deploy. In this example, we’re going to configure conetix/conetix-demo-theme:
- Select Clone on the right hand side, then copy the SSH based URL:
- Return to the Plesk config and paste the URL into the dialog:
Do not hit OK yet.
- On the right hand side within Plesk, click on the httpdocs folder:
- 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”
All files will be replaced if you select an existing folder.
- Double check that the desired folder has now been set:
- Take a copy the SSH public key:
Do not click on OK yet.
- Then, go back to the browser tab with GitLab open.
- On the left hand side, go to Settings -> Repository:
- Expand out the Deployment Keys, then add a name (of your choosing), then paste the SSH key in and click Add key:
- You should then see a confirmation that the key has been added:
- 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:
- After the initial deployment, you should then see a summary screen with the Git configuration. Select Repository Settings:
- Take a copy of the webhook URL:
- Return to the browser window with GitLab then select Settings -> Webhooks:
- Add the URL in and leave the default trigger of push events enabled:
If you have multiple branches, you can filter the push events just to that branch only if required under push events.
- Click on Add Webhook to save.
- You can now click Test within the webhook and it should return a 204 to confirm it worked:
- Return to the Plesk browser window and simply cancel the dialog to edit the Repository Settings (we just needed open to copy the webhook).
- 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: