name: Frontend

on: pull_request


jobs:
  eslint:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master

    - name: ESLint checks
      uses: ./.github/eslint-action
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  check-and-preview:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
    - uses: actions/setup-python@v1
      with:
        python-version: '3.7.4'
    - name: Install dependencies
      working-directory: backend
      run: pip install -r requirements/prod.txt
    - run: yarn
      working-directory: frontend
    - run: |
        cd backend/
        DEBUG=True SECRET_KEY=DEMO python manage.py migrate
        DEBUG=True SECRET_KEY=DEMO python manage.py loaddata demodata/conferences.json
        DEBUG=True SECRET_KEY=DEMO python manage.py runserver &

        cd ../frontend/
        yarn build

        yarn codegen
    - run: yarn tsc
      working-directory: frontend
    - uses: netlify/actions/cli@master
      with:
        args: deploy --dir=frontend/public/
      env:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

name: Frontend

on: pull_request


jobs:
  eslint:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master

    - name: ESLint checks
      uses: ./.github/eslint-action
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  check-and-preview:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
    - uses: actions/setup-python@v1
      with:
        python-version: '3.7.4'
    - name: Install dependencies
      working-directory: backend
      run: pip install -r requirements/prod.txt
    - run: yarn
      working-directory: frontend
    - run: |
        cd backend/
        DEBUG=True SECRET_KEY=DEMO python manage.py migrate
        DEBUG=True SECRET_KEY=DEMO python manage.py loaddata demodata/conferences.json
        DEBUG=True SECRET_KEY=DEMO python manage.py runserver &

        cd ../frontend/
        yarn build

        yarn codegen
    - run: yarn tsc
      working-directory: frontend
    - uses: netlify/actions/cli@master
      with:
        args: deploy --dir=frontend/public
      env:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

  preview-docs:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
    - run: yarn
      working-directory: frontend
    - run: yarn build:docz
      working-directory: frontend
    - uses: netlify/actions/cli@master
      with:
        args: deploy --dir=frontend/.docz/dist
      env:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_DOCS }}

Build docs on github actions
Build docs on github actions
