From 29eb05c09466fc745617e21c03fe8529e51b867b Mon Sep 17 00:00:00 2001 From: Alina Marquardt Date: Tue, 4 Apr 2023 22:24:59 +0200 Subject: [PATCH] initial commit --- .gitignore | 35 +++++++++++++++++++++++++++++++++++ deploy_bitbucket.php | 39 +++++++++++++++++++++++++++++++++++++++ deploy_github.php | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100755 .gitignore create mode 100755 deploy_bitbucket.php create mode 100644 deploy_github.php diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..185edd8 --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/deploy_bitbucket.php b/deploy_bitbucket.php new file mode 100755 index 0000000..ace93de --- /dev/null +++ b/deploy_bitbucket.php @@ -0,0 +1,39 @@ +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"', +*/ \ No newline at end of file diff --git a/deploy_github.php b/deploy_github.php new file mode 100644 index 0000000..57284b9 --- /dev/null +++ b/deploy_github.php @@ -0,0 +1,37 @@ +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"', +*/