Skip to content

Instantly share code, notes, and snippets.

@rohmann
Last active December 21, 2015 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohmann/6326472 to your computer and use it in GitHub Desktop.
Save rohmann/6326472 to your computer and use it in GitHub Desktop.
Simple script for use with GitHub web hooks
<?php
//Only allow requests from Github (see: https://gist.github.com/webtekk/6326465)
if (!githubOrigin()) die('Unauthorized');
$data = json_decode($_POST['payload'],true);
//Only continue if this commit is on the master branch
if (!$data['ref'] == 'refs/heads/master') die('Not a master branch commit');
//Pass the repo name and URL through to our shell script (see: https://gist.github.com/webtekk/6326294)
shell_exec('cd '.dirname(__FILE__).'; ./gitarchivemaster.sh '.$data['repository']['url'].' '.$data['repository']['name']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment