# 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: php:7.2-fpm

pipelines:
  default:
    - step:
        script:
          - apt-get update && apt-get install -qy git curl libmcrypt-dev default-mysql-client
          - yes | pecl install mcrypt-1.0.1
          - docker-php-ext-install pdo_mysql
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install
          - ln -f -s .env.pipelines .env
          - php artisan migrate
          - php artisan serve &
          - sleep 5
          - ./vendor/bin/phpunit
          - curl -vk http://localhost:8000
        services:
          - mysql

    - step:
            deployment: staging
            script:
              - cat ./deploy.sh
              - echo "Staging Deploy step finished"
    - step:
            deployment: production
            trigger: manual
            script:
              #Update Image
              - apt-get update

definitions:
  services:
    mysql:
      image: mysql:5.7
      environment:
        MYSQL_DATABASE: 'homestead'
        MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
        MYSQL_USER: 'homestead'
        MYSQL_PASSWORD: 'secret'