Skip to content
This repository was archived by the owner on Mar 15, 2021. It is now read-only.

skrajewski/gitlab-hook-receiver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitLab Hook Receiver 0.1.1

Helper to GitLab hook services.

What it is?

It's a simple set of class to help create GitLab POST Hook. At this moment it supports Push Events.

How it works?

Imagine you have a project in VCS. Always when you push commits to the master branch your production server automatically pull all changes. Are you use composer? You can transfer special command through commit message to run composer install on production. See example.

Install

Install via composer or put it directly to composer.json file and run composer update.

require: {
    "szykra/gitlab-hook-receiver": "0.1.*"
}

##Example

$directory = '/path/to/your/project/directory';

// Instance of Logger, in this case it's Monolog
$logger = new Logger("ON_PUSH", [new StreamHandler('hook.log')]);

// Create new Receiver and inject instance of Logger
$receiver = new GitLabRequestReceiver($logger);

// Set Gitlab POST data to Receiver Object
$receiver->prepareData(file_get_contents('php://input'));

// Add GitPullCommandListener to Receiver, argument is your git repository
// It automatically pull changes from current project branch
$receiver->addCommandListener(new GitPullCommandListener($directory));

// Add ComposerCommandListener to Receiver, argument is your project directory with composer.json file
// Now you can transfer composer action through commit message e.g. [composer:update]
$receiver->addCommandListener(new ComposerCommandListener($directory));

// Run all listeners
$receiver->run();

About

Helper to GitLab hook services.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages