robbertkl / deployhook
Basic git deployment script meant for service hooks
Requires
- php: >=5.4
- m6web/firewall: ~0.3
Requires (Dev)
- apigen/apigen: 2.*
- squizlabs/php_codesniffer: 1.*
This package is not auto-updated.
Last update: 2019-09-29 02:04:37 UTC
README
PHP library for adding a git deployment script to use as a service hook, for example on GitHub or Bitbucket.
DeployHook is PSR-0, PSR-1 and PSR-2 compliant.
Semantic Versioning is used for releases / tags.
Setup
- Add this to your website's
composer.json
file:
"require": { "robbertkl/deployhook": "1.*" }
-
Install it by running composer and make sure your
composer.lock
is added to the repo as well; do not gitignore it! -
Add a script (e.g.
deploy.php
) or route to your website/app to execute the deployer; see examples/features.php for an example of such a script -
Commit all of this into your repo and push it to GitHub or Bitbucket
-
On the server, make sure the webserver user (usually
apache
orwww
) has an existing home dir, for example/var/www
; on some platforms, the webserver user has a non-existent home dir, which has to be changed -
If needed, create an SSH key for the webserver user:
sudo -Hu www ssh-keygen -t rsa
# Leave the passphrase empty!
-
Add the public key (from
/var/www/.ssh/id_rsa.pub
) as a deployment key for the GitHub or Bitbucket repo (in the repo settings) -
Now, as the webserver user, clone the repo on the server in a location you want to serve it from:
sudo -Hu www git clone git@github.com:user/repo.git my-repo-clone
cd my-repo-clone/
- Initialize and fetch submodules:
sudo -Hu www git submodule update --init
- Install the composer dependencies:
sudo -Hu www composer install
- Finally, add a service hook to GitHub ("Webhook") or Bitbucket ("POST hook") in the repo settings using the URL of the script you've added (e.g.
http://username:password@www.example.org/deploy.php
)
Documentation
See the examples/ dir for usage examples. Also, check out the API documentation, generated using ApiGen.
Authors
- Robbert Klarenbeek, robbertkl@renbeek.nl
License
DeployHook is published under the MIT License.