Skip to content

Instantly share code, notes, and snippets.

@bernard-ng
Created October 9, 2019 20:09
Show Gist options
  • Save bernard-ng/4c0b02bd234a8d3126cd59db0920d4fe to your computer and use it in GitHub Desktop.
Save bernard-ng/4c0b02bd234a8d3126cd59db0920d4fe to your computer and use it in GitHub Desktop.
update a website after a github commit
#!/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