Requires
- illuminate/support: ^11.36
Requires (Dev)
- larastan/larastan: ^v3.0.2
- laravel/pint: ^1.19.0
- orchestra/testbench: ^v9.9.0
- pestphp/pest: ^v3.7.1
- phpstan/phpstan: ^2.1.0
This package is auto-updated.
Last update: 2025-01-10 15:17:19 UTC
README
This package wraps the GitHub CLI for easy use in Laravel. We only use this as a dev dependency and everyone on our team has the GitHub CLI installed and authenticated locally. Using this as a non-dev dependency and managing the authentication on a remote server is beyond the scope of this documentation.
Installation
composer require artisan-build/gh
Configuration
[Warning] The default configuration file is optimized for how we use this package. It is set up to do some risky things like archive or delete repositories without confirmation. Carefully read the GitHub CLI documentation and edit the configuration file to meet your organization's needs
Usage
We've basically just created a fluid wrapper around the GitHub CLI, using the Laravel Process facade to actually run the commands. Below is a sample of what can be done. Please refer to the tests and the GitHub CLI documentation for a fuller view of what is possible with this package.
Auth
// Login using web GH::auth()->login(null, null, true); // Logout GH::auth()->logout('github.com'); // Check status GH::auth()->status();
Browse
// Open a repository GH::browse('username/repository')->open(); // Open a specific branch GH::browse('username/repository')->open('main'); // Open a specific commit GH::browse('username/repository')->open(null, 'abc123');
Cache
// List caches GH::cache()->list(); // Delete a cache GH::cache()->delete('cache-key-123'); // Restore a cache GH::cache()->restore('cache-key-123');
Codespace
// Create a codespace GH::codespace()->create('username/repository', 'main', 'standardLinux'); // Stop a codespace GH::codespace()->stop('codespace-name'); // View logs GH::codespace()->logs('codespace-name');
Config
// Get a configuration value GH::config()->get('editor'); // Set a configuration value GH::config()->set('editor', 'vim'); // List all configuration values GH::config()->list();
Gist
// Create a gist GH::gist()->create(['file1.txt'], 'Test Gist', true); // View a gist GH::gist()->view('gist-id', true); // Delete a gist GH::gist()->delete('gist-id');
GPG Key
// Add a GPG key GH::gpgKey()->add('path/to/key.gpg'); // List GPG keys GH::gpgKey()->list(); // Delete a GPG key GH::gpgKey()->delete('12345');
Issue
// Create a new issue GH::issue('username/repository')->create('Issue Title', 'Issue Body', ['--label bug']); // Edit an issue GH::issue('username/repository')->edit('123', 'Updated Title', 'Updated Body'); // Close and reopen an issue GH::issue('username/repository')->close('123'); GH::issue('username/repository')->reopen('123'); // Comment on an issue GH::issue('username/repository')->comment('123', 'This is a comment.');
Label
// Create a label GH::label('username/repository')->create('bug', 'Indicates a bug', 'FF0000'); // Edit a label GH::label('username/repository')->edit('bug', 'fixed-bug', 'Resolved', '00FF00'); // Delete a label GH::label('username/repository')->delete('bug');
Organization
// View organization details GH::org('organization-name')->view(); // List members GH::org('organization-name')->members(); // List pending invitations GH::org('organization-name')->invitations();
Pull Request
// Create a new pull request GH::pr('username/repository')->create('PR Title', 'PR Body', ['--base main', '--draft']); // Edit a pull request GH::pr('username/repository')->edit('123', 'Updated Title', 'Updated Body'); // Merge a pull request GH::pr('username/repository')->merge('123', true); // Squash merge // Close and reopen a pull request GH::pr('username/repository')->close('123'); GH::pr('username/repository')->reopen('123');
Project
// List projects GH::project('organization-name')->list(); // View project details GH::project('organization-name')->view(123); // Create a project GH::project('organization-name')->create('New Project'); // Delete a project GH::project('organization-name')->delete(123);
Release
// Create a release GH::release('username/repository')->create('v1.0.0', 'Release Title', 'Release Notes'); // Upload an asset to a release GH::release('username/repository')->uploadAsset('v1.0.0', 'path/to/file.zip', 'Asset Label'); // Delete a release GH::release('username/repository')->delete('v1.0.0');
Repository
// Create a new repository GH::repo('username/repository')->create(); // Clone a repository GH::repo('username/repository')->clone('directory', 'https'); // Archive a repository GH::repo('username/repository')->archive();
Ruleset
// Create a ruleset GH::ruleset('username/repository')->create([ 'name' => 'My Ruleset', 'enforcement' => 'active', ]); // Enable a ruleset GH::ruleset('username/repository')->enable('123');
Workflow Run
// List workflow runs GH::run('username/repository')->list(); // View a workflow run GH::run('username/repository')->view('123'); // Rerun a workflow GH::run('username/repository')->rerun('123');
Search
// Search repositories GH::search()->repos('laravel'); // Search issues GH::search()->issues('bug label:bug');
Secret
// Set a secret GH::secret('username/repository')->set('MY_SECRET', 'secret-value'); // Delete a secret GH::secret('username/repository')->delete('MY_SECRET');
Status
// View status GH::status()->show();
Variable
// List variables GH::variable('username/repository')->list(); // Set a variable GH::variable('username/repository')->set('ENV_VAR', 'value123');
Workflow
// Enable a workflow GH::workflow('username/repository')->enable('workflow.yml'); // Disable a workflow GH::workflow('username/repository')->disable('workflow.yml');
Memberware
This package is part of our internal toolkit and is optimized for our own purposes. We do not accept issues or PRs in this repository.