A simple yet powerful PHP tool to catch Git webhooks from GitLab, GitHub & Bitbucket and deploy your projects to your server after pushing.
Deepl.io catches and then acts on post requests sent by your git service-provider using webhooks. Currently github.com,
gitlab.com and bitbucket.org are supported.
You
configure your repository to send push-updates to your Deepl.io instance running on your server via Webhooks. Check the repository setting for the appropriate options. Deepl.io will check if the request comes from the right source,
detects if the branch that has been updated is correct and then executes your custom PHP or shell commands. Deepl.io only calls your commands, it does not act on it's own since this would be way too inflexible.
Download Deepl.io to your server or clone using Git. Consider creating a subdomain:
deploy.yourserver.com
.
Requirements: PHP, and your web host needs to allow php exec commands and mod_rewrite
has to be enabled.
Open config/config.example.json
and rename it to config.json
. Set a secret token and maybe configure allowed IPs.
You can configure the repositoryPath to a location outside the deepl.io path to use your own git repo for the deploy-configuration:
"repositoriesPath": "./../my-own-deployment-repositories/"
Then, add this to the webhook settings of your Git provider:
deploy.yourserver.com/your-secret-token
Right now, you need to configure your deploys manually. It's pretty simple: Open the repositories/
folder, create a new folder corresponding with your Git repository name and add 3 files:
your-repo.git
/branch.config.json
containing information (name, repository_ssh_url, branch) required to identify your deployment.
your-repo.git
/branch.script.php / .sh
contains the code that should be executed when the hook is called. PHP scripts take precedence over shell scripts since they can call themselves.
your-repo.git
/branch.request.json
(optional) containing a test JSON payload.
The branch.
part is needed to distinguish push events only for the desired branch.
Example Structure:
deepl.io.git
/master.config.json
deepl.io.git
/master.script.sh
deepl.io.git
/master.request.json
Make sure to set the "enabled" flag to enable execution
{ "enabled": true, "project": { "name": "Example Music Project", "repository_ssh_url": "git@example.com:music/example.git", "branch": "deploy/test" }, "mails": { "michael.jackson@gmail.com": "Michael Jackson", "tina.turner@gmail.com": "Tina Turner" } }
It is important, that the "repository_ssh_url" matches the repository that your service provider delivers using the JSON payload. You can test this by calling /admin/ (protected by .htaccess, only works localy)
and updating the example request branch.request.json
:
"repository": { "git_ssh_url":"git@example.com:music/example.git", },GitHub JSON:
"repository": { "ssh_url": "git@github.com:music/example.git", },Bitbucket JSON:
Create repository_ssh_url
using the full repository name found in the json:
"repository": { "full_name": "music/example", },
git@bitbucket.org:
+ {full_name}
+ .git
converts to git@bitbucket.org:music/example.git
Check logs/deeplio.log
if you have any problems or open up an issue.