name: Build Envision and Docs

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.17.x]

    steps:
      - uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Install dependencies
        run: |
          yarn

      - name: Lint
        run: |
          yarn lint

      - name: Build
        run: |
          yarn workspace envision run build

      - name: Archive production artifacts
        uses: actions/upload-artifact@v1
        with:
          name: dist
          path: packages/envision/dist

      - uses: actions/upload-artifact@v2
        with:
          name: docs
          path: docs

  deploy:
    needs: build
    if: github.event_name == 'push' && github.ref == 'refs/heads/master'

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/download-artifact@v2
        with:
          name: docs
          path: docs

      - name: Display structure of downloaded files
        run: ls -R

      - name: Deploy to GitHub Pages
        uses: JamesIves/github-pages-deploy-action@3.7.1
        with:
          ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
          BRANCH: gh-pages
          FOLDER: docs

name: Build Envision and Docs

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.17.x]

    steps:
      - uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Install dependencies
        run: |
          yarn

      - name: Lint
        run: |
          yarn lint

      - name: Build
        run: |
          yarn build

      - name: Archive production artifacts
        uses: actions/upload-artifact@v1
        with:
          name: dist
          path: packages/envision/dist

      - uses: actions/upload-artifact@v2
        with:
          name: docs
          path: docs

  deploy:
    needs: build
    if: github.event_name == 'push' && github.ref == 'refs/heads/master'

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/download-artifact@v2
        with:
          name: docs
          path: docs

      - name: Display structure of downloaded files
        run: ls -R

      - name: Deploy to GitHub Pages
        uses: JamesIves/github-pages-deploy-action@3.7.1
        with:
          ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
          BRANCH: gh-pages
          FOLDER: docs

Build all packages in master
Build all packages in master
