-
-
Save brnpimentel/5f276d1611898785dbd5055363b35b4d to your computer and use it in GitHub Desktop.
git pull - with .env & laravel
This file contains hidden or 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
GIT_DIR="/dir" | |
GIT_KEY="key" | |
GIT_BRANCH="refs/heads/master" |
This file contains hidden or 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 | |
if (file_exists('../githook.sh')) { | |
$json = file_get_contents('php://input'); | |
$jsarr = json_decode($json, true); | |
$branch = $jsarr["ref"]; | |
if (!$branch || !isset($_GET['key'])) { | |
header("HTTP/1.0 500 Internal Server Error"); | |
print_r($json); | |
die('Error'); | |
} | |
echo shell_exec('sh ../githook.sh ' . $_GET['key'] . ' ' . $branch); | |
} else { | |
header("HTTP/1.0 500 Internal Server Error"); | |
die('No file'); | |
} |
This file contains hidden or 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
#!/bin/sh | |
if [ $# -eq 0 ]; then | |
echo "No arguments supplied" | |
exit 1 | |
fi | |
. ../.env | |
HOME=$(cd ~ && pwd) | |
export HOME=$(cd ~ && pwd) | |
#alias php='/usr/bin/php-cli' | |
if [ -z ${GIT_DIR+x} ]; then | |
echo "No GIT_DIR on .env" | |
exit 1 | |
fi | |
if [ -z ${GIT_KEY+x} ]; then | |
echo "No GIT_KEY on .env" | |
exit 1 | |
fi | |
if [ "$1" != "${GIT_KEY}" ]; then | |
echo 'Wrong KEY' | |
exit 1 | |
fi | |
#App directories | |
GIT_LOG="${GIT_DIR}/git.log" | |
echo "Checking out" >> ${GIT_LOG} | |
cd ${GIT_DIR} | |
git pull origin ${GIT_BRANCH} >> ${GIT_LOG} | |
echo "Composer install & Dumpautoload & Running optimizations" >> ${GIT_LOG} | |
php-cli -d allow_url_fopen=1 -d detect_unicode=0 composer.phar install >> ${GIT_LOG} | |
echo "Laravel Clearing Cache" >> ${GIT_LOG} | |
php-cli artisan cache:clear >> ${GIT_LOG} | |
echo "Chmoding Storage" >> ${GIT_LOG} | |
chmod -R g+w storage | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment