name: Documentation generation

on:
  push:
    branches:
      - master

jobs:
  lint:
    name: Generate docs and push to github pages
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Read .nvmrc
        run: echo ::set-output name=NVMRC::$(cat .nvmrc)
        id: nvm

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '${{ steps.nvm.outputs.NVMRC }}'

      - name: Set up yarn
        run: npm install --global yarn

      - name: Set up dependencies
        run: yarn

      - name: Generate docs
        run: yarn docs

      - name: Deploy Github Page
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./docs
