# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:12.6.0

pipelines:
  default:
    - step:
        caches:
          - node
        name: Deploy to test server
        deployment: test
        script:
          - apt-get update && apt-get install -y unzip
          - npm install
          - npm run build

  custom:
    staging:
      - step:
          caches:
            - node
          name: Deploy to staging server
          deployment: staging
          script:
            - apt-get update && apt-get install -y unzip
            - apt-get install -y openssh-server
            - ssh -tt $APP_URL -l $DEPLOY_SERVER_USERNAME << EOF
            - cd www/staging/trs_pwa
            - git stash
            - git pull origin develop
            - npm install
            - npm run build


