Author: Afaan Bilal
Project Page: afaan.dev/gitlab-autodeploy
GitLab AutoDeploy v2 is a PHP script to easily deploy web app repositories on git push
. It
is based on a similar script I wrote for GitHub. The v2 is a complete
rewrite of the original with the major change being that only changes are deployed instead of a complete
redeployment. So you need to manually deploy at least once and then let it work its magic.
- No SSH access required.
- No shell access required.
- Fully compatible with shared servers.
- Public, internal and private repos are supported.
- Download gitlab-autodeploy-v2.php.
- Update the
[PRIVATE_TOKEN]
and[REPO_ID]
with your GitLab Private token and Project ID. - Set the deploy directory by replacing
[DEPLOY_DIR]
relative to the script. - Set your timezone.
- Upload the script to your server.
- On GitLab, add a WebHook to your repo for a
push
event (or any other) and set it to the uploaded script. - You're done!
Now, whenever you git push
to your gitlab repo, it will be automatically deployed
to your web server!
- Your private token can be found in your GitLab profile in
Profile Settings
»Account
. - For your project ID, go to https://gitlab.com/api/v3/projects/?private_token=PRIVATE-TOKEN (Replace PRIVATE-TOKEN with your private token)
- Find your project in the returned JSON and copy the ID associated with it.
You must have administrative access to the repo for adding WebHooks
- Go to your GitLab repo »
Settings
»Web Hooks
. - Enter the URL of the gitlab-autodeploy.php script in the
URL
field. - If your server does not use SSL, then uncheck
Enable SSL Verification
. - Leave everything else as is, click
Add Web Hook
. - You're done!
All contributions are welcome. Please create an issue first for any feature request or bug. Then fork the repository, create a branch and make any changes to fix the bug or add the feature and create a pull request. That's it! Thanks!
GitLab AutoDeploy v2 is released under the MIT License. Check out the full license here.