language: node_js
node_js:
  - "lts/*"
cache:
  directories:
    - "node_modules"

before_install:
  - pip install --user awscli
  - export PATH=$PATH:$HOME/.local/bin

install:
  - npm install

script:
  - npm run-script build

before_deploy:
 - source ./scripts/deploytarget.sh

deploy:
  provider: s3
  access_key_id: ${AWS_ACCESS_KEY_ID}
  secret_access_key: ${AWS_SECRET_ACCESS_KEY}
  bucket: ${DEPLOY_TARGET}
  skip_cleanup: true
  region: "us-east-1"
  local_dir: dist
  on: 
    condition: -n "${DEPLOY_TARGET}"

# TODO S3 deploy doesn't sync the directory, only adds new files: use AWS CLI to sync

language: node_js
node_js:
  - "lts/*"
cache:
  directories:
    - "node_modules"

before_install:
  - pip install --user awscli
  - export PATH=$PATH:$HOME/.local/bin

install:
  - npm install

script:
  - npm run-script build

after_success:
 - source ./scripts/deploytarget.sh

deploy:
  provider: s3
  access_key_id: ${AWS_ACCESS_KEY_ID}
  secret_access_key: ${AWS_SECRET_ACCESS_KEY}
  bucket: ${DEPLOY_TARGET}
  skip_cleanup: true
  region: "us-east-1"
  local_dir: dist
  on: 
    condition: -n "${DEPLOY_TARGET}"

# TODO S3 deploy doesn't sync the directory, only adds new files: use AWS CLI to sync

Move the deploy target selection to after_success
Move the deploy target selection to after_success
