initial commit
commit
29eb05c094
|
@ -0,0 +1,35 @@
|
|||
# Deploy
|
||||
logs
|
||||
|
||||
# Created by https://www.gitignore.io/api/macos
|
||||
# Edit at https://www.gitignore.io/?templates=macos
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# End of https://www.gitignore.io/api/macos
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
// SETUP
|
||||
$ref = 'master';
|
||||
$logfile = 'logs/deploy-log.txt';
|
||||
|
||||
$input = json_decode(file_get_contents('php://input')); // BitBucket payload
|
||||
$remoteref = $input->push->changes[0]->new->name;
|
||||
|
||||
// LOGIC
|
||||
if ($remoteref == $ref) {
|
||||
$commands = array(
|
||||
'echo $PWD',
|
||||
'whoami',
|
||||
'git pull',
|
||||
'git status',
|
||||
);
|
||||
$log = "####### ".date('Y-m-d H:i:s'). " #######\n";
|
||||
$log .= 'deploying ref: '.$ref;
|
||||
echo 'deploying ref: '.$ref;
|
||||
foreach($commands AS $command){
|
||||
$tmp = shell_exec("$command 2>&1");
|
||||
$log .= "\n\$ $command\n".trim($tmp)."\n";
|
||||
}
|
||||
$log .= "\n";
|
||||
file_put_contents($logfile,$log,FILE_APPEND);
|
||||
} else if(!isset($remoteref)) {
|
||||
die('no ref');
|
||||
} else {
|
||||
die('wrong ref: '.$remoteref);
|
||||
}
|
||||
|
||||
// OTHER HELPFUL COMMANDS
|
||||
/*
|
||||
'git submodule sync',
|
||||
'git submodule update',
|
||||
'git submodule status',
|
||||
'test -e /usr/share/update-notifier/notify-reboot-required && echo "system restart required"',
|
||||
*/
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
// SETUP
|
||||
$ref = 'refs/heads/master';
|
||||
$logfile = 'logs/deploy-log.txt';
|
||||
|
||||
// LOGIC
|
||||
$payload = json_decode($_POST['payload']); // GitHub payload
|
||||
if ($payload->ref == $ref) {
|
||||
$commands = array(
|
||||
'echo $PWD',
|
||||
'whoami',
|
||||
'git pull',
|
||||
'git status',
|
||||
);
|
||||
$log = "####### ".date('Y-m-d H:i:s'). " #######\n";
|
||||
$log .= 'deploying ref: '.$ref;
|
||||
echo 'deploying ref: '.$ref;
|
||||
foreach($commands AS $command){
|
||||
$tmp = shell_exec("$command 2>&1");
|
||||
$log .= "\n\$ $command\n".trim($tmp)."\n";
|
||||
}
|
||||
$log .= "\n";
|
||||
file_put_contents($logfile,$log,FILE_APPEND);
|
||||
} else if(!isset($payload->ref)) {
|
||||
die('no ref');
|
||||
} else {
|
||||
die('wrong ref: '.$payload->ref);
|
||||
}
|
||||
|
||||
// OTHER HELPFUL COMMANDS
|
||||
/*
|
||||
'git submodule sync',
|
||||
'git submodule update',
|
||||
'git submodule status',
|
||||
'test -e /usr/share/update-notifier/notify-reboot-required && echo "system restart required"',
|
||||
*/
|
Loading…
Reference in New Issue