Last active
August 27, 2021 20:42
-
-
Save frecklebit/df3ef6cdd59516762b8132fb50494769 to your computer and use it in GitHub Desktop.
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 | |
# Deploys current branch to Zoro team environment | |
# e.g. deploy-qa browse-d | |
deploy-qa() { | |
# Make sure current directory is clean | |
if [[ -n "$(git status --untracked-files=no --porcelain)" ]]; then | |
echo "Please commit your work before deploying to QA" | |
return 1 | |
fi | |
# Store arguments to variables | |
env=$1 | |
if [[ -z "$env" ]]; then | |
read -p "Which team environment are you deploying to? " env | |
fi | |
# Update the environment variable | |
env="env/$env" | |
# Determine paths | |
current_path=$(pwd) | |
zoro_path="$WORKING_DIR/zoro" | |
if [ "$current_path" != "$zoro_path" ]; then | |
echo "Changing to Zoro's working directory.." | |
cd $zoro_path | |
fi | |
# Get the current git branch | |
branch=$(git_current_branch) | |
# Make sure branch isn't master or development | |
if [[ $branch =~ ^(master|develop|development)$ ]]; then | |
read -p "Which branch would you like to deploy to $env? " branch | |
fi | |
echo "Deploying branch '$branch' to environment '$env'..." | |
# Checkout environment branch | |
git checkout $env | |
# Hard reset branch | |
git reset --hard $branch | |
# Push code to origin | |
git push origin $env --force | |
# Switch back to working branch | |
git checkout $branch | |
echo "Done!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment