notifications:
  email: false

language: node_js

node_js:
- node

addons:
  ssh_known_hosts:
  - $DEPLOY_HOST

env:
  global:
  - BUILD_PATH=dist
  matrix:
  - ENV=development
  - ENV=staging NODE_ENV=production PUBLIC_PATH=/sabor-website/
  - ENV=production NODE_ENV=production PUBLIC_PATH=/cu/sabor/

cache:
  directories:
  - node_modules

before_script:
- openssl aes-256-cbc -k $ENCRYPTION_KEY -in .npmrc.enc -out .npmrc -d

script:
- npm run build

before_deploy:
- ssh-keyscan -t $TRAVIS_SSH_KEY_TYPES -H $DEPLOY_HOST 2>&1 | tee -a $HOME/.ssh/known_hosts
- openssl aes-256-cbc -k $ENCRYPTION_KEY -in deploy_key.enc -out deploy_key -d
- eval "$(ssh-agent -s)"
- chmod 400 deploy_key
- ssh-add deploy_key

deploy:
- provider: pages
  local_dir: $BUILD_PATH
  skip_cleanup: true
  github_token: $GITHUB_TOKEN
  on:
    branch: master
    condition:
    - $ENV = staging
- provider: script
  skip_cleanup: true
  script:
  - rsync -r --delete-after $BUILD_PATH/* $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH
  on:
    branch: production
    condition:
    - $ENV = production

notifications:
  email: false

language: node_js

node_js:
- node

addons:
  ssh_known_hosts:
  - $DEPLOY_HOST

env:
  global:
  - BUILD_PATH=dist
  matrix:
  - ENV=development
  - ENV=staging NODE_ENV=production PUBLIC_PATH=/sabor-website/
  - ENV=production NODE_ENV=production PUBLIC_PATH=/cu/sabor/

cache:
  directories:
  - node_modules

before_script:
- openssl aes-256-cbc -k $ENCRYPTION_KEY -in .npmrc.enc -out .npmrc -d

script:
- npm run build

before_deploy:
- ssh-keyscan -t $TRAVIS_SSH_KEY_TYPES -H $DEPLOY_HOST 2>&1 | tee -a $HOME/.ssh/known_hosts
- openssl aes-256-cbc -k $ENCRYPTION_KEY -in deploy_key.enc -out deploy_key -d
- eval "$(ssh-agent -s)"
- chmod 400 deploy_key
- ssh-add deploy_key

deploy:
- provider: pages
  local_dir: $BUILD_PATH
  skip_cleanup: true
  github_token: $GITHUB_TOKEN
  on:
    branch: master
    condition:
    - $ENV = staging
- provider: script
  skip_cleanup: true
  script:
  - rsync -r --delete-after $BUILD_PATH/* $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH
  on:
    branch: master
    condition:
    - $ENV = production

Deploy to production on master branch as well (delete production branch).
Deploy to production on master branch as well (delete production branch).
