Skip to content

Instantly share code, notes, and snippets.

@mikepsinn
Last active March 14, 2018 23:43
Show Gist options
  • Save mikepsinn/34b93aaf8172140c44b3146dfdbcf7e2 to your computer and use it in GitHub Desktop.
Save mikepsinn/34b93aaf8172140c44b3146dfdbcf7e2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# curl https://gist.githubusercontent.com/mikepsinn/34b93aaf8172140c44b3146dfdbcf7e2/raw/pre_deploy_web_jenkins.sh | bash -s ${GITHUB_ACCESS_TOKEN}
if [ -z ${GIT_COMMIT} ]; then
echo "GIT_COMMIT not set!"
exit 1
fi
echo "Using GITHUB_ACCESS_TOKEN $1"
GITHUB_ACCESS_TOKEN=$1
curl https://gist.githubusercontent.com/mikepsinn/00a4153544a31bb6c645da13e4a9a26e/raw/git_config.sh | bash -s ${GITHUB_ACCESS_TOKEN}
export RELEASE_FOLDER=/home/ubuntu/releases/${GIT_COMMIT}
if [ ! -d ${RELEASE_FOLDER} ];
then
echo "${RELEASE_FOLDER} not found so building app.."
else
echo "${RELEASE_FOLDER} already exists so no need to build again"
exit 0
fi
if [ ! -f /var/run/php/php7.1-fpm.sock ]; then
echo "/var/run/php/php7.1-fpm.sock not found!"
#exit 1
fi
if [ ! -d ~/QM-Docker ];
then
echo "Cloning QM-Docker..."
curl https://gist.githubusercontent.com/mikepsinn/2f3c69a17e22855421e15541e0f2f973/raw/clone_qm.sh | bash -s ${GITHUB_ACCESS_TOKEN}
fi
OLD_ACCESS_TOKEN=ca2b964b9a256f2719945a4b4eec58f797e075cc
echo "cd ~/QM-Docker/.git && sed -i s/${OLD_ACCESS_TOKEN}/${GITHUB_ACCESS_TOKEN}/g config"
cd ~/QM-Docker/.git && sed -i 's/${OLD_ACCESS_TOKEN}/${GITHUB_ACCESS_TOKEN}/g' config
echo "cd ~/QM-Docker && git pull origin develop && git reset --hard ${GIT_COMMIT} && git submodule update --init --recursive"
cd ~/QM-Docker && git pull origin develop && git reset --hard ${GIT_COMMIT} && git submodule update --init --recursive
source ~/QM-Docker/slim/scripts/copy_env.sh
if [ ! -d ${RELEASE_FOLDER} ];
then
echo "${RELEASE_FOLDER} not found so building app.."
composer install && test -e success || exit 1
else
echo "${RELEASE_FOLDER} already exists so no need to build again"
fi
mkdir ${RELEASE_FOLDER} || true
sudo rsync -am --stats ~/QM-Docker/ ${RELEASE_FOLDER}/ --exclude .git/ --exclude node_modules/ --exclude phantomjs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment