# This is a sample build configuration for JavaScript.
# Check our guides at https://confluence.atlassian.com/x/14UWN 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.
# https://support.atlassian.com/bitbucket-cloud/docs/laravel-with-bitbucket-pipelines/
image: lorisleiva/laravel-docker:7.3

options:
  max-time: 10

definitions:
  caches:
    vendor: vendor

pipelines:
  branches:
    master:
      - step:
          name: Build
          caches:
            - composer
            - node
            - vendor
          script:
            - composer install
            # - vendor/bin/phpunit
      - step:
          name: Publish
          deployment: Production-SCP
          script:
            - pipe: atlassian/scp-deploy:0.3.3
              variables:
                USER: ${USER_APP}
                SERVER: ${SERVER_APP}
                REMOTE_PATH: ${PATH_APP}
                LOCAL_PATH: ${LOCAL_PATH}
      - step:
          name: Exec
          deployment: Production-SSH
          script:
            - pipe: atlassian/ssh-run:0.2.6
              variables:
                SSH_USER: ${USER_APP}
                SERVER: ${SERVER_APP}
                COMMAND: ${COMMAND_APP}
    staging:
      - step:
          name: Build
          caches:
            - composer
            - node
            - vendor
          script:
            - composer install
            - vendor/bin/phpunit
      - step:
          name: Publish
          deployment: Staging-SCP
          script:
            - pipe: atlassian/scp-deploy:0.3.12
              variables:
                USER: ${USER_APP}
                SERVER: ${SERVER_APP}
                REMOTE_PATH: ${PATH_APP}
                LOCAL_PATH: ${LOCAL_PATH}
      - step:
          name: Exec
          deployment: Staging-SSH
          script:
            - pipe: atlassian/ssh-run:0.2.6
              variables:
                SSH_USER: ${USER_APP}
                SERVER: ${SERVER_APP}
                COMMAND: ${COMMAND_APP}
