Created
October 9, 2019 20:09
-
-
Save bernard-ng/4c0b02bd234a8d3126cd59db0920d4fe to your computer and use it in GitHub Desktop.
update a website after a github commit
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
#!/bin/sh | |
set -e | |
if [ ! -f /var/www/html/public/doDeploy ]; then | |
exit; | |
fi | |
rm /var/www/html/public/doDeploy | |
STAMP=$(date +%s) | |
WORKDIR=/tmp/$STAMP | |
NEWDIR=$WORKDIR/new | |
BACKUPDIR=$WORKDIR/old | |
mkdir -p $WORKDIR | |
mkdir -p $NEWDIR | |
mkdir -p $BACKUPDIR | |
git clone repo-url.git $NEWDIR | |
#(cd $NEWDIR && git checkout develop) | |
(cd $NEWDIR && composer install) | |
(cd $NEWDIR && mkdir data/logs) | |
cp /var/www/html/.env $NEWDIR/ | |
mv /var/www/html/* $BACKUPDIR/ | |
mv /var/www/html/.env $BACKUPDIR/ | |
mv $NEWDIR/* /var/www/html | |
mv $NEWDIR/.env /var/www/html | |
chown -R ec2-user:apache /var/www/html/ | |
chown -R ec2-user:apache /var/www | |
chmod 2775 /var/www && find /var/www -type d -exec chmod 2775 {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment