sagor / github-updater
A Laravel package for automated Github pulls and Artisan commands by moh-sagor.
Requires
- php: ^7.2 || ^8.0
- illuminate/support: ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
- symfony/process: ~3.4 || ^4.4 || ^5.0 || ^6.0 || ^7.0 || ^8.0
Requires (Dev)
- orchestra/testbench: ^3.5 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
- phpunit/phpunit: ^8.5 || ^9.0 || ^10.0 || ^11.0 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Automated GitHub repository updates and Artisan command deployment pipeline for Laravel.
๐ Overview
sagor/github-updater is a high-performance Laravel package designed to simplify and automate repository pulling and post-update deployment tasks. With support for Laravel 5.5 up to Laravel 13.x and PHP 7.2 through PHP 8.4+, it provides a seamless way to pull updates from private or public GitHub repositories and execute chained Artisan commands (migrations, seeders, cache clearing, optimization) in a single action.
Whether triggered via Artisan CLI or the built-in Web Terminal route (with real-time streaming output), github-updater ensures your application stays updated effortlessly.
โจ Features
- ๐ Universal Compatibility: Full support for Laravel versions
5.5,5.8,6.x,7.x,8.x,9.x,10.x,11.x,12.x, and13.x. - ๐ Modern & Legacy PHP Support: Tested and compatible across PHP
7.2,7.4,8.0,8.1,8.2,8.3, and8.4+. - ๐ Secure Authentication: Supports Personal Access Tokens (PAT) and custom repository URLs.
- โก Artisan Command Chaining: Run multiple Artisan tasks sequentially after pull (e.g.,
migrate --force,db:seed,config:cache). - ๐ฅ๏ธ Web Terminal UI: Built-in dark-themed web terminal output with real-time autoscrolling logs.
- ๐ป Console Integration: Dedicated
php artisan github:pullcommand for server scripts and CRON tasks. - ๐ฆ Zero-Config Auto Discovery: Automatically registers package service providers and aliases.
๐๏ธ Architecture & Execution Flow
The following diagram illustrates how requests flow through GithubUpdater:
flowchart TD
subgraph Triggers ["Deployment Triggers"]
A["๐ Web Request: GET /github-pull"]
B["๐ป CLI Command: php artisan github:pull"]
end
subgraph Package ["GithubUpdater Core Engine"]
C{"Router / Controller"}
D{"Console Handler"}
E["Load Configuration<br/>(config/github-updater.php)"]
F["Build Git URL with PAT Token<br/>(https://user:token@repo.git)"]
G["Run 'git pull' Subprocess"]
H["Parse ARTISAN_COMMANDS Pipeline"]
I["Execute Chained Artisan Commands"]
end
subgraph Outputs ["Execution Feedback"]
J["๐ฅ๏ธ Streamed Web Terminal UI"]
K["๐ Console Log Output"]
end
A --> C
B --> D
C --> E
D --> E
E --> F
F --> G
G --> H
H --> I
I -->|Web Output| J
I -->|CLI Output| K
Loading
๐ Compatibility Matrix
| Technology | Supported Versions | Notes |
|---|---|---|
| Laravel Framework | ^5.5, ^5.8, ^6.0, ^7.0, ^8.0, ^9.0, ^10.0, ^11.0, ^12.0, ^13.0 |
Full backward & forward compatibility |
| PHP Runtime | ^7.2, ^7.4, ^8.0, ^8.1, ^8.2, ^8.3, ^8.4+ |
Handles cross-version polyfills & processes |
| Symfony Process | ~3.4, ^4.4, ^5.0, ^6.0, ^7.0, ^8.0 |
Adapts dynamically to installed Symfony components |
๐ฅ Installation
Install the package into your Laravel project using Composer:
composer require sagor/github-updater
Service Provider Registration
For Laravel projects using Package Auto-Discovery, the service provider will automatically register.
If auto-discovery is disabled in your project, manually add GithubUpdaterServiceProvider to the providers array in config/app.php:
'providers' => [ // ... Sagor\GithubUpdater\Providers\GithubUpdaterServiceProvider::class, ],
โ๏ธ Configuration
Publish the package configuration file to your application's config/ directory:
php artisan vendor:publish --tag=config
Or target the specific provider:
php artisan vendor:publish --provider="Sagor\GithubUpdater\Providers\GithubUpdaterServiceProvider"
This creates config/github-updater.php:
<?php return [ /* |-------------------------------------------------------------------------- | GitHub Personal Access Token |-------------------------------------------------------------------------- | Your GitHub Personal Access Token (PAT) used for authenticating | private repository git operations. */ 'github_token' => env('GITHUB_TOKEN', ''), /* |-------------------------------------------------------------------------- | GitHub Username / Organization |-------------------------------------------------------------------------- | The owner username or organization of the repository. */ 'github_username' => env('GITHUB_USERNAME', ''), /* |-------------------------------------------------------------------------- | Repository Link |-------------------------------------------------------------------------- | Target repository URL (e.g. github.com/username/repository.git) */ 'github_repo_link' => env('GITHUB_REPO_LINK', ''), /* |-------------------------------------------------------------------------- | Post-Pull Artisan Commands |-------------------------------------------------------------------------- | Comma-separated list of Artisan commands executed sequentially after | a successful git pull. */ 'artisan_commands' => env('ARTISAN_COMMANDS', 'php artisan migrate --force, php artisan db:seed'), ];
Environment Variables (.env)
Add and configure the following variables in your project's .env file:
GITHUB_TOKEN=ghp_YourPersonalAccessToken1234567890 GITHUB_USERNAME=your-github-username GITHUB_REPO_LINK=github.com/your-username/your-repository.git ARTISAN_COMMANDS="php artisan migrate --force, php artisan db:seed, php artisan config:cache"
โ ๏ธ Security Reminder: Never commit your
GITHUB_TOKENto version control. Always set it inside server.envfiles.
๐ Usage
1. CLI Artisan Command
To perform an update directly from the command line or CI/CD deployment scripts:
php artisan github:pull
What it does:
- Connects to GitHub using your configured authentication parameters.
- Executes
git pullfrom the remote repository branch. - Sequentially executes all Artisan commands listed in
ARTISAN_COMMANDS. - Outputs execution progress directly to stdout.
2. Web Interface (/github-pull)
Access the streaming terminal interface via browser:
GET /github-pull
Interface Highlights:
- Custom terminal dark mode container.
- ASCII Banner display.
- Real-time line-by-line output streaming with autoscroll support.
Customizing Middleware & Route Security
By default, the /github-pull route uses the web middleware group. To restrict access to authorized users or admins, group the route in your routes/web.php file:
use Sagor\GithubUpdater\Controllers\GithubController; Route::middleware(['web', 'auth', 'can:manage-deployments'])->group(function () { Route::get('/github-pull', [GithubController::class, 'executeCommands']) ->name('github.pull'); });
๐ Security Best Practices
- Protect Web Routes: Always wrap
/github-pullwith authentication middleware (auth, admin roles) to prevent unauthorized execution. - Token Permissions: Scope your GitHub Personal Access Token (PAT) with minimum required permissions (
repo:status,repo_deployment, orcontents:read). - Environment Security: Keep
.envpermissions strict (chmod 600 .env) on production servers.
๐งช Testing
The package includes a full PHPUnit test suite using Orchestra Testbench. To run unit and feature tests:
vendor/bin/phpunit
Test Coverage Includes:
- Service Provider Registration & Config Merging.
- Named Route Binding (
github.pull). - Artisan Command Registration (
github:pull).
๐ License
The MIT License (MIT). Please see LICENSE for more information.
๐จโ๐ป Author & Support
Developed and maintained by Md Sagor Hossain (sagorhassain4@gmail.com).
- GitHub: @moh-sagor
- Repository: github.com/moh-sagor/github-updater
If you find this package helpful, please give it a โญ๏ธ on GitHub!
