highsolutions / github-hook
A Laravel package for simple Continuous Integration based on GitHub push.
Installs: 1 021
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=7.1.3
- illuminate/support: 5.*|^6.0|^7.0|^8.0
- laravel/slack-notification-channel: ^2.0
README
Easy continuous integration based on GitHub.
Installation
Add the following line to the require
section of your Laravel webapp's composer.json
file:
"require": { "HighSolutions/github-hook": "*" }
Run composer update
to install the package.
This package uses Laravel 5.5 Package Auto-Discovery.
For previous versions of Laravel, you need to update config/app.php
by adding an entry for the service provider:
'providers' => [ // ... HighSolutions\GitHubHook\GitHubHookServiceProvider::class, ];
Configuration
Finally, from the command line again, publish the default configuration file:
php artisan vendor:publish --provider="HighSolutions\GitHubHook\GitHubHookServiceProvider"
and you can specify some essentials settings (in ENV and in config file called github-hook.php
):
You can specify whole configuration in .env file:
GITHUB_HOOK_URL=/github/hook/ GITHUB_HOOK_BRANCH=master GITHUB_HOOK_SECRET= GIHUB_HOOK_BEFORE="php artisan help###php artisan help" GITHUB_HOOK_HOOK_MIGRATION="php artisan migrate --force" GITHUB_HOOK_HOOK_SEED="php artisan db:seed --force" GITHUB_HOOK_HOOK_REFRESH="php artisan migrate:refresh --seed --force" GITHUB_HOOK_HOOK_COMPOSER="php composer.phar install --no-dev" GITHUB_HOOK_HOOK_CACHE="php artisan cache:clear" GITHUB_HOOK_HOOK_VIEW="php artisan view:clear" GIHUB_HOOK_AFTER="php artisan help###php artisan optimize" GITHUB_HOOK_HOOK_SENDER=GitHub GITHUB_HOOK_SLACK_CHANNEL= GITHUB_HOOK_SLACK_URL=
Remember surround values containg spaces with "
.
No Laravel version
This package is also configured to work not within Laravel. We recommend:
- Create
hook
folder - Copy whole package to this folder
- Create another file (e.g.
awesome_hook.php
) and paste in it:
<?php require_once 'github-hook/src/Services/GitHubHookService.php'; HighSolutions\GitHubHook\Services\GitHubHookService::simpleInit([ 'secret' => null, // secret of webhook 'branch' => 'master', // branch name 'path' => '/home/www/', // absolute path to the repo ], $_POST['payload'], $_SERVER['x-hub-signature'], [ 'composer' => 'composer install --no-dev', ]);
Configure GitHub webhook to access this second file and voila!
You can also upload only service file github-hook/src/Services/GitHubHookService.php
and then you need to change path to:
<?php require_once 'GitHubHookService.php'; ...
Changelog
0.11.0
- Support Laravel 9.0, 10, and 11.x
0.9.0
- Support Laravel 8.0
0.8.1
- Add slack-notification-channel dependency
0.8.0
- Support Laravel 7.0
0.7.0
- Support Laravel 6.0
0.6.0
- Support Laravel 5.8
0.5.0
- Add before and after hooks
0.4.1
- Wrong package in Auto-Discovery definition.
0.4.0
- Support Package Auto-Discovery
composer install --no-dev
instead ofcomposer update --no-scripts
as default command for composer hook
0.3.0
- cache and view clear commands
0.2.3
- ping request fixes
0.2.0
- no Laravel example
- no edit flag in git push
- support for ping request
- composer's hook
- hooks declarations
- conditional hooks based on committed files
0.1.0
- created package
- events
- slack notification
- hash verification
Roadmap
- Asynchronous option
- Comments
- Unit tests!
Credits
This package is developed by HighSolutions, software house from Poland in love in Laravel.