name: Deploy

on:
  release:
    types: [created]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: npm ci
      - run: npm run setup
      - run: npm run build
      - run: npm test

  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/
      - run: npm ci
      - run: npm run setup
      - run: npm run build
      - name: Deploy
        uses: burnett01/rsync-deployments@4.1
        with:
          switches: -avzr --delete
          path: build/
          remote_path: mon.arbre.app
          remote_host: mon.arbre.app
          remote_user: github
          remote_key: ${{ secrets.DEPLOY_KEY }}
      - name: Archive production artifacts
        uses: actions/upload-artifact@v2
        with:
          name: build
          path: build
