Skip to content

πŸ¦₯ Simple PHP webhook deployment system for GitHub repositories with SSH authentication and post-deployment commands.

License

Notifications You must be signed in to change notification settings

lemmon/php-git-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PHP Git Deploy

A lightweight, self-hosted Git deployment system written in PHP. Deploy your code with webhooks or manual triggers - works with any web project.

License: MIT PHP Version

πŸš€ Features

  • 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

πŸ“ Directory Structure

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

⚑ Quick Start

  1. Download the latest release or clone this repository
  2. Upload the _deploy/ folder to your web root
  3. Configure your repository in _deploy/config.php
  4. Generate SSH keys using _deploy/tools/ssh-keygen.php
  5. Add public key to your GitHub repository
  6. Test deployment by visiting the webhook URL

πŸ”§ Configuration

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',
    ],
];

πŸ”— Usage

GitHub Webhook Setup

  1. Go to your repository Settings β†’ Webhooks β†’ Add webhook
  2. Set Payload URL: https://yoursite.com/_deploy/webhook.php
  3. Set Content type: application/x-www-form-urlencoded (tested) or application/json
  4. Set Secret: Use the same value as deploy_token in your config
  5. Select Just the push event
  6. Click Add webhook

Note: Manual deployment is not currently available for security reasons. Deployment only works via authenticated GitHub webhooks.

πŸ› οΈ Tools

  • tools/system-check.php - Check server compatibility
  • tools/ssh-keygen.php - Generate SSH keys for GitHub
  • tools/setup-composer.php - Download and setup composer.phar
  • tools/find-php.php - Find correct PHP executable path

πŸ“‹ Requirements

  • PHP 7.0+
  • Git (command line access)
  • SSH or HTTPS repository access
  • Web server with PHP support

πŸ”’ Security

  • Token-based authentication
  • SSH key support for private repositories
  • No credentials stored in web-accessible files
  • Configurable deployment directory

🌟 Why PHP Git Deploy?

  • 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

πŸ“– Documentation

See individual tool files for detailed usage instructions.

🀝 Contributing

Contributions welcome! Please feel free to submit a Pull Request.

πŸ“„ License

MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Created by Jakub PelΓ‘k


Deploy your code with confidence! πŸš€

About

πŸ¦₯ Simple PHP webhook deployment system for GitHub repositories with SSH authentication and post-deployment commands.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages