Skip to content

Instantly share code, notes, and snippets.

@wicochandra
Created July 12, 2018 08:59
Show Gist options
  • Save wicochandra/569e7bbf724bf206144784a72eff6de3 to your computer and use it in GitHub Desktop.
Save wicochandra/569e7bbf724bf206144784a72eff6de3 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
ROOT_DIR=versions/$(date +%Y%m%d_%H%M%S)
read -p "Enter tag name: " TAG
read -p "Enter Bitbucket Username: " USERNAME
read -sp "Enter Bitbucket Password: " PASSWORD
echo git clone https://${USERNAME}@GIT_URL $ROOT_DIR --depth 1
git clone https://${USERNAME}:${PASSWORD}@GIT_URL $ROOT_DIR --depth 1
echo "moving to $(pwd)/$ROOT_DIR";
cd $ROOT_DIR;
echo "git fetch origin $TAG"
git fetch origin refs/tags/$TAG:refs/tags/$TAG
echo "Checkout $TAG..."
git checkout $TAG
echo "Cleaning git..."
git remote remove origin
git remote add origin GIT_HTTPS
rm -f .env
ln -srf ../../shared/.env ./.env
rm -rf storage/logs
ln -srf ../../shared/storage/logs storage/logs
npm install
composer install
npm run production
echo -e "\033[0;33mDeployed successful to ${ROOT_DIR}\033[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment