Last active
August 29, 2015 14:02
-
-
Save guweigang/931190f85c86db3c56de to your computer and use it in GitHub Desktop.
gitlab trigger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fs = fopen('./cycle_hook.log', 'a'); | |
$client_ip = $_SERVER['REMOTE_ADDR']; | |
fwrite($fs, 'Request on ['.date("Y-m-d H:i:s").'] from ['.$client_ip.']'.PHP_EOL); | |
$json = file_get_contents('php://input'); | |
$data = json_decode($json, true); | |
fwrite($fs, 'Data: '.print_r($data, true).PHP_EOL); | |
fwrite($fs, '======================================================================='.PHP_EOL); | |
$fs and fclose($fs); | |
// 執行上面所述的 update.sh | |
echo "<pre>"; | |
echo shell_exec("/bin/sh ". __DIR__ . '/update.sh'); | |
echo '</pre>'; | |
/* | |
update.sh | |
#!/bin/bash | |
cd /home/work/source/git/vsfinance_cycle/ui/ | |
/home/work/local/git/bin/git remote update -p | |
/home/work/local/git/bin/git checkout -f develop | |
/home/work/local/git/bin/git pull | |
cd /home/work/source/git/vsfinance_cycle/fe/ | |
/home/work/local/git/bin/git remote update -p | |
/home/work/local/git/bin/git checkout -f dev | |
/home/work/local/git/bin/git pull | |
cd /home/work/source/git/vsfinance_cycle/skeleton/ | |
/home/work/local/git/bin/git remote update -p | |
/home/work/local/git/bin/git checkout -f master | |
/home/work/local/git/bin/git pull | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment