A lightweight, self-hosted Git deployment system written in PHP. Deploy your code with webhooks or manual triggers - works with any web project.
- GitHub webhook support - Automatic deployments on push
- Manual deployment triggers - Deploy via URL with token
- SSH key authentication - Secure private repository access
- Incremental updates - Smart git pull for existing repositories
- Configurable commands - Run composer, artisan, or any post-deploy scripts
- Plain text logging - Perfect for webhook logs and debugging
- No dependencies - Pure PHP, works on shared hosting
your-website/
βββ index.html # Your website files
βββ assets/
βββ .git/ # Git repository
βββ _deploy/ # Deployment system
βββ webhook.php # Main webhook handler
βββ config.php # Configuration file
βββ tools/ # Helper tools
β βββ system-check.php
β βββ ssh-keygen.php
β βββ setup-composer.php
β βββ find-php.php
βββ keys/ # SSH keys (create this)
β βββ deploy_key
β βββ deploy_key.pub
βββ logs/ # Logs (auto-created)
βββ deploy.log
- Download the latest release or clone this repository
- Upload the
_deploy/
folder to your web root - Configure your repository in
_deploy/config.php
- Generate SSH keys using
_deploy/tools/ssh-keygen.php
- Add public key to your GitHub repository
- Test deployment by visiting the webhook URL
Edit _deploy/config.php
:
<?php
return [
'repository' => [
'url' => '[email protected]:username/repo.git',
'branch' => 'main',
],
'deployment' => [
'target_directory' => '..',
'post_commands' => [
__DIR__ . '/composer.phar install --no-dev --optimize-autoloader --no-interaction',
],
],
'security' => [
'deploy_token' => 'your-secret-token-here',
],
'ssh' => [
'key_path' => './keys/deploy_key',
],
'logging' => [
'log_file' => './logs/deploy.log',
],
];
- Go to your repository Settings β Webhooks β Add webhook
- Set Payload URL:
https://yoursite.com/_deploy/webhook.php
- Set Content type:
application/x-www-form-urlencoded
(tested) orapplication/json
- Set Secret: Use the same value as
deploy_token
in your config - Select Just the push event
- Click Add webhook
Note: Manual deployment is not currently available for security reasons. Deployment only works via authenticated GitHub webhooks.
tools/system-check.php
- Check server compatibilitytools/ssh-keygen.php
- Generate SSH keys for GitHubtools/setup-composer.php
- Download and setup composer.phartools/find-php.php
- Find correct PHP executable path
- PHP 7.0+
- Git (command line access)
- SSH or HTTPS repository access
- Web server with PHP support
- Token-based authentication
- SSH key support for private repositories
- No credentials stored in web-accessible files
- Configurable deployment directory
- Lightweight - No complex setup or dependencies
- Shared hosting friendly - Works on basic PHP hosting
- Self-contained - All tools included
- GitHub integrated - Perfect webhook support
- Developer friendly - Clean logs and error messages
See individual tool files for detailed usage instructions.
Contributions welcome! Please feel free to submit a Pull Request.
MIT License - see the LICENSE file for details.
Created by Jakub PelΓ‘k
- GitHub: @lemmon
- Repository: php-git-deploy
Deploy your code with confidence! π