-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci: add new dev env support * ci: prefix image tag with k8s- * ci: fix image tag * ci: staging ignore test * ci: env fix * ci: alexa name fix * ci: env fix * ci: add context * ci: test * ci: unique branch * ci: add envcli support * ci: add non-interactive init * ci: remove envcli init * ci: add env name * ci: non-interactive mode * chore: clean up test file * chore: double quotes
- Loading branch information
(Frank) Yu Cheng Gu
authored
May 18, 2020
1 parent
8431de3
commit cd273d0
Showing
3 changed files
with
133 additions
and
25 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ] | ||
then | ||
echo "ERROR: No environment supplied!" | ||
echo "Usage: yarn preview:new [environment name]" | ||
exit 1 | ||
fi | ||
|
||
ENV_NAME=$1 | ||
CURRENT_BRANCH=$(git branch --show-current) | ||
DEV_BRANCH_NAME="${ENV_NAME}_$(date +%s)" # Simply use the env-adjective-noun_epoch as the branch name | ||
|
||
echo -e "Pushing your code to CD pipeline..." | ||
{ # Suppress command outputs since it's not relevant for the end-user | ||
git stash save "PREDEV_STASH" # Stash changes with this name if applicable | ||
git branch -D "$DEV_BRANCH_NAME" # Force delete the ephemeral branch for safety | ||
git checkout -b "$DEV_BRANCH_NAME" | ||
git push --force --set-upstream origin "$DEV_BRANCH_NAME" --no-verify | ||
|
||
git checkout "$CURRENT_BRANCH" | ||
|
||
STASH_NAME=$(git stash list | head -1 | awk -F'. ' ' { print $NF }') | ||
if [ "$STASH_NAME" == "PREDEV_STASH" ]; then | ||
git stash pop # Only pop if the previous stash is made by the ephemeral environments preview | ||
fi | ||
git branch -D "$DEV_BRANCH_NAME" # Force delete the ephemeral branch to prevent direct user modification | ||
} &> /dev/null | ||
|
||
echo -e "Your code has been pushed! Please check CircleCI for deployment details: https://app.circleci.com/pipelines/github/voiceflow/alexa?branch=$DEV_BRANCH_NAME" |