image: node:8
pipelines:
    custom:
        staging:
            - step:
                name: Composer install
                image: composer
                script:
                    - composer install --ignore-platform-reqs --no-scripts
                artifacts:
                    - vendor/**
            - step:
                name: Build htaccess
                script:
                    - IFS=
                    - echo $(<$BITBUCKET_CLONE_DIR/public/.htaccess.production) >> $BITBUCKET_CLONE_DIR/public/.htaccess
                artifacts:
                    - public/.htaccess
            - step:
                deployment: staging
                name: Rsync to Staging server
                script:
                    - apt-get update && apt-get install -y ssh rsync
                    - rsync -zrSlhuK --delete -e 'ssh -p 2020' --ignore-times --stats --info=progress2 --exclude-from=$BITBUCKET_CLONE_DIR/deployment_exclude.txt $BITBUCKET_CLONE_DIR/ $USERNAME@$IP:$DEPLOY_PATH
                    - ssh $USERNAME@$IP -p 2020 'ea-php72 bin/console c:c'
        production:
            - step:
                name: Composer install
                image: composer
                script:
                    - composer install --ignore-platform-reqs --no-scripts
                artifacts:
                    - vendor/**
            - step:
                name: Build htaccess
                script:
                    - IFS=
                    - echo $(<$BITBUCKET_CLONE_DIR/public/.htaccess.production) >> $BITBUCKET_CLONE_DIR/public/.htaccess
                artifacts:
                    - public/.htaccess
            - step:
                deployment: production
                name: Rsync to Production server
                script:
                    - apt-get update && apt-get install -y ssh rsync
                    - rsync -zrSlhuK --delete -e 'ssh -p 2020' --ignore-times --stats --info=progress2 --exclude-from=$BITBUCKET_CLONE_DIR/deployment_exclude.txt $BITBUCKET_CLONE_DIR/ $USERNAME@$IP:$DEPLOY_PATH
                    - ssh $USERNAME@$IP -p 2020 'php bin/console c:c'
