Skip to content

Github php webhook to sync repository data into multiple servers (via ftp and ssh protocols)

Notifications You must be signed in to change notification settings

Coppertino/github-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this?

This project was created to make easier the procedure of updating production servers with new versions of other projects (generally it was designed for web applications, but there is no limitation of use).

Overall effect is an upgraded git cloning, which gives you the opportunity to merge new changes straight to the testing and production servers with appropriate real configurations, while hiding these configurations from public repositories.

For example, you have some project ‘A’, which is already in production stage and a copy of it with changed production settings is hosted somewhere. All is fine for some time, but then you want to add a new feature or fix some bugs / security issues. With webhook you can make and commit changes to test branch, immediately test it and commit to master branch, which will be automatically synced to production server with saved production settings.

How it works

Synchronization goes in 4 steps:
1. Permission checks (IP filtering)
2. Validation and processing of incoming parameters
3. Forming the list of tasks to synchronize
4. Repository cloning (or pulling if already cached), replacing configuration files and uploading to the server(s)

How to install

What will you need to use webhook:

  • Installed Git and webhook
  • Hosting place (with (s)ftp or ssh+rsync access)
  • Project you want to sync

How to setup GitHub:
You will need admin rights for your project on GitHub. Go to admin panel and set notification URL to the webhook ‘post-commit.php’ file on your server as shown here

How to setup webhook config:
Make a copy of ‘sample.config.user.php’ and name it ‘config.user.php’. This file contains all settings (with examples) users should change in order to use webhook.

How to override project configuration files with real ones

At the moment, to save and not share user configuration files for different projects, webhook uses special folder (‘sync-configs/’), which ‘overrides’ project configurations. In this folder you should create a subfolder associated with your project, which will contain the structure of the original project, but will have only configuration files. The name of this subfolder you should enter in ‘$repo_conf’ variable as ‘config_folder’ parameter.
Example:
You have project ‘Abc’ with such folder structure:

-|
 |- configs
   |- common.config.php
   |- some_other.config.php
 |- other_folder
   |- other_important_file.php
   |- ...
 |- index.php

Structure you will have in ‘sync-configs/’ folder:

-|
 |- Abc
   |- configs
     |- common.config.php
     |- some_other.config.php

What you will have in ‘$repo_conf’ variable:

$repo_conf = array(
	'http://github.com/company_name/Abc' => array(
		'branch'	=> 'master',
		'hosts'		=> 'production',
		'repo_path'	=> '',
		'server_path'	=> 'Abc',
		'config_folder'	=> 'Abc'
	)
);

About

Github php webhook to sync repository data into multiple servers (via ftp and ssh protocols)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages