PHP code example of sagor / github-updater

1. Go to this page and download the library: Download sagor/github-updater library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sagor / github-updater example snippets


'providers' => [
    // ...
    Sagor\GithubUpdater\Providers\GithubUpdaterServiceProvider::class,
],



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

use Sagor\GithubUpdater\Controllers\GithubController;

Route::middleware(['web', 'auth', 'can:manage-deployments'])->group(function () {
    Route::get('/github-pull', [GithubController::class, 'executeCommands'])
        ->name('github.pull');
});
mermaid
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:[email protected])"]
        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
bash
php artisan vendor:publish --tag=config
bash
php artisan vendor:publish --provider="Sagor\GithubUpdater\Providers\GithubUpdaterServiceProvider"
env
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"
bash
php artisan github:pull