On every hosting plan you can connect a website to a repository on GitHub (or GitLab, Bitbucket). After every git push the server pulls the changes and puts them on the site.
- Log in to Plesk and choose Git for the domain.
- Choose Remote repository and paste the repository address, e.g.
https://github.com/company/site.git. - Private repository? Use the SSH address (
git@github.com:company/site.git). Plesk shows a public key: add it in GitHub under Settings → Deploy keys (read access is enough). - Leave the deployment path as
httpdocs(the site's main folder) or choose another folder. - Set the deployment mode to automatic and click OK.
Automatically on every push
In the repository settings in Plesk, copy the webhook URL. In GitHub, open Settings → Webhooks → Add webhook, paste it and save. From then on every push to the chosen branch goes straight to the site.
Commands after deployment
Under Deployment actions you can add commands that run after each deployment, such as composer install --no-dev or clearing a cache. Do not keep passwords or a .env file with credentials in the repository.
Want to check changes first? Deploy a test branch to a subdomain, e.g. test.yourcompany.com.