pipelines:
  branches:
    custom:
      - step:
          script:
            - echo "Deploying to live site"
      - step:
          name: 'Install composer packages'
          image: composer:2.5
          script:
            - composer install --ignore-platform-reqs
          artifacts:
            - vendor/**
      - step:
          size: 4x
          runtime:
            cloud:
              atlassian-ip-ranges: true
          name: 'Sync vendor'
          deployment: master
          script:
            - pipe: atlassian/rsync-deploy:0.8.1
              name: 'rsync vendor files'
              variables:
                SSH_USER: '$LIVEUSER'
                USER: '$LIVEUSER'
                SERVER: '$LIVEIP'
                REMOTE_PATH: '$LIVEFOLDER/vendor'
                LOCAL_PATH: 'vendor/'
            - pipe: atlassian/ssh-run:0.4.0
              variables:
                SSH_USER: '$LIVEUSER'
                MODE: 'command'
                SERVER: '$LIVEIP'
                PORT: 22
                COMMAND: 'cd $LIVEFOLDER && git status --porcelain && git fetch && git add . && git stash && git pull && git status && chmod 644 ./db/migrations/*.php && ./vendor/bin/phinx migrate'
    custom_no_composer:
      - step:
          script:
            - echo "Deploying to live site without composer install"
      - step:
          size: 4x
          runtime:
            cloud:
              atlassian-ip-ranges: true
          name: 'Deploy'
          deployment: master
          script:
            - pipe: atlassian/rsync-deploy:0.8.1
              name: 'rsync db migration files'
              variables:
                SSH_USER: '$LIVEUSER'
                USER: '$LIVEUSER'
                SERVER: '$LIVEIP'
                REMOTE_PATH: '$LIVEFOLDER/db/migrations'
                LOCAL_PATH: 'db/migrations/'
            - pipe: atlassian/ssh-run:0.4.0
              variables:
                SSH_USER: '$LIVEUSER'
                MODE: 'command'
                SERVER: '$LIVEIP'
                PORT: 22
                COMMAND: 'cd $LIVEFOLDER && git status --porcelain && git fetch && git add . && git stash && git pull && git status && ./vendor/bin/phinx migrate'