Allow deploying to arbitrary AWS environments

- Use a single deploy job in CircleCI with a regex filter
- Allow overriding the deploy env via command-line argument, otherwise
use $CIRCLE_BRANCH

Pushes to the 'production', 'staging', or branches matching 'deploy-*'
will be pushed to the corresponding AWS environment (this is determined
by the prefix you set in the poa-explorer-infra script)
pull/181/head
Paul Schoenfelder 7 years ago
parent 41efc21fa5
commit 4c2b7b9f16
  1. 43
      .circleci/config.yml
  2. 9
      bin/deploy

@ -141,7 +141,7 @@ jobs:
- run: mix local.hex --force
- run: mix credo
deploy_production:
deploy_aws:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.6.4
@ -157,28 +157,8 @@ jobs:
- "c4:fd:a8:f8:48:a8:09:e5:3e:be:30:62:4d:6f:6f:36"
- run:
name: Deploy Production to AWS
command: bin/deploy production
deploy_staging:
docker:
# Ensure .tool-versions matches
- image: circleci/elixir:1.6.4
working_directory: ~/app
steps:
- attach_workspace:
at: .
- add_ssh_keys:
fingerprints:
- "c4:fd:a8:f8:48:a8:09:e5:3e:be:30:62:4d:6f:6f:36"
- run:
name: Deploy Staging to AWS
command: bin/deploy staging
name: Deploy to AWS
command: bin/deploy
dialyzer:
docker:
# Ensure .tool-versions matches
@ -344,20 +324,13 @@ workflows:
- credo:
requires:
- build
- deploy_production:
filters:
branches:
only: production
requires:
- check_formatted
- credo
- eslint
- sobelow
- test
- deploy_staging:
- deploy_aws:
filters:
branches:
only: master
only:
- production
- staging
- /deploy-[A-Za-z0-9]+$/
requires:
- check_formatted
- credo

@ -62,12 +62,13 @@ function deploy_chain() {
}
# Make sure we got an environment as an argument to this script
DEPLOY_ENV="$1"
DEPLOY_ENV="${1:-$CIRCLE_BRANCH}"
if [ -z "$DEPLOY_ENV" ]; then
error "Expected deployment environment as an argument, but none was provided!"
error "Expected deployment environment as an argument or via \$CIRCLE_BRANCH, but neither was provided!"
fi
# Convert it to uppercase for environment variable lookups
DEPLOY_ENV="$(echo "$DEPLOY_ENV" | tr '[:lower:]' '[:upper:]')"
# Strip deploy- prefix if one was set and convert it
# to uppercase for environment variable lookups
DEPLOY_ENV="$(echo "$DEPLOY_ENV" | sed -e 's/^deploy-//' | tr '[:lower:]' '[:upper:]')"
log "Deploying to environment '${DEPLOY_ENV}'"

Loading…
Cancel
Save