name: Build&Deploy

on:
  push:
    branches: [ main ]

jobs:
  build-deploy:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Validate composer.json and composer.lock
      run: composer validate

    - name: Cache Composer packages
      id: composer-cache
      uses: actions/cache@v2
      with:
        path: vendor
        key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
        restore-keys: |
          ${{ runner.os }}-php-

    - name: Install dependencies
      if: steps.composer-cache.outputs.cache-hit != 'true'
      run: composer install --prefer-dist --no-progress --no-suggest

    - name: Create stacks directory
      run: mkdir stacks
      
    - name: Install dependencies in default stack
      uses: Accelys/action-robo@master
      env:
        PHPMAE_SHARED_SECRET: ${{ secrets.PHPMAE_SHARED_SECRET }}
      with:
        task: 'install:stack coid://phpmae.cloudobjects.io/DefaultStack'

    - name: Deploy with fly
      uses: superfly/flyctl-actions@1.1
      env:
        FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
      with:
        args: deploy

name: Build&Deploy

on:
  push:
    branches: [ main ]

jobs:
  build-deploy:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Validate composer.json and composer.lock
      run: composer validate

    - name: Cache Composer packages
      id: composer-cache
      uses: actions/cache@v2
      with:
        path: vendor
        key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
        restore-keys: |
          ${{ runner.os }}-php-

    - name: Install dependencies
      if: steps.composer-cache.outputs.cache-hit != 'true'
      run: composer install --prefer-dist --no-progress --no-suggest

    - name: Create stacks directory
      run: mkdir stacks

    - name: Make composer available to robo
      run: cp `which composer` ./composer.phar
      
    - name: Install dependencies in default stack
      uses: Accelys/action-robo@master
      env:
        PHPMAE_SHARED_SECRET: ${{ secrets.PHPMAE_SHARED_SECRET }}
      with:
        task: 'install:stack coid://phpmae.cloudobjects.io/DefaultStack'

    - name: Deploy with fly
      uses: superfly/flyctl-actions@1.1
      env:
        FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
      with:
        args: deploy

Make composer available to robo
Make composer available to robo