A lightweight, self-hosted Git deployment system written in PHP. Deploy your code via webhooks or manual triggers and keep any web project in sync.
- 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
- Submodule aware - Recursively clones and updates git submodules
- 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_tokenin your config - Select Just the push event
- Click Add webhook
For manual deployments or integration with systems that don't support GitHub's webhooks, you can trigger a deployment by visiting a special URL. This method is less secure than the default webhook validation and must be explicitly enabled.
- In
_deploy/config.php, setallow_token_deploymenttotrue. - Make sure you have set a strong, secret
deploy_token. - Trigger a deployment by visiting:
https://yoursite.com/_deploy/webhook.php?token=your-secure-token-here
Security Warning: Anyone with this URL can trigger a deployment. Use a long, random token and only enable this feature if you understand the risks.
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.