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 local.hex --force
- run: mix credo - run: mix credo
deploy_production: deploy_aws:
docker: docker:
# Ensure .tool-versions matches # Ensure .tool-versions matches
- image: circleci/elixir:1.6.4 - 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" - "c4:fd:a8:f8:48:a8:09:e5:3e:be:30:62:4d:6f:6f:36"
- run: - run:
name: Deploy Production to AWS name: Deploy to AWS
command: bin/deploy production command: bin/deploy
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
dialyzer: dialyzer:
docker: docker:
# Ensure .tool-versions matches # Ensure .tool-versions matches
@ -344,20 +324,13 @@ workflows:
- credo: - credo:
requires: requires:
- build - build
- deploy_production: - deploy_aws:
filters:
branches:
only: production
requires:
- check_formatted
- credo
- eslint
- sobelow
- test
- deploy_staging:
filters: filters:
branches: branches:
only: master only:
- production
- staging
- /deploy-[A-Za-z0-9]+$/
requires: requires:
- check_formatted - check_formatted
- credo - credo

@ -62,12 +62,13 @@ function deploy_chain() {
} }
# Make sure we got an environment as an argument to this script # 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 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 fi
# Convert it to uppercase for environment variable lookups # Strip deploy- prefix if one was set and convert it
DEPLOY_ENV="$(echo "$DEPLOY_ENV" | tr '[:lower:]' '[:upper:]')" # to uppercase for environment variable lookups
DEPLOY_ENV="$(echo "$DEPLOY_ENV" | sed -e 's/^deploy-//' | tr '[:lower:]' '[:upper:]')"
log "Deploying to environment '${DEPLOY_ENV}'" log "Deploying to environment '${DEPLOY_ENV}'"

Loading…
Cancel
Save