image: php:8.1-fpm

definitions:
  steps:
    - step: &php-build
        name: Build PHP
        caches:
          - composer
        script:
          - apt-get update && apt-get install -qy unzip git curl libmcrypt-dev
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer --version
          - php -v
          - php -m
          - composer update --ignore-platform-reqs
        artifacts:
          - vendor/**
    - step: &deploy-develop
        name: Deploy (Develop)
        deployment: Develop
        caches:
          - composer
        script:
          - apt-get update && apt-get install -qy unzip git curl libmcrypt-dev rsync
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer --version
          - composer global require "laravel/envoy"
          - ~/.composer/vendor/bin/envoy run deploy --branch="develop"

pipelines:
  default:
    - step: *php-build
  branches:
    master:
      - step: *php-build
      - step: *deploy-develop
    develop:
      - step: *php-build
      - step: *deploy-develop
