name: gh-pages

on:
  workflow_run:
    workflows:
      - "stacks-blockchain-api"
    branches:
      - master
    types:
      - completed
  workflow_dispatch:

jobs:
  gh-pages:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Use Node.js
        uses: actions/setup-node@v2
        with:
          node-version-file: '.nvmrc'

      - name: Build OpenAPI redoc, Typescript types, and client library docs
        run: npm run build:docs

      - name: Deploy gh-pages
        uses: JamesIves/github-pages-deploy-action@4.0.0
        with:
          branch: gh-pages
          folder: docs/.tmp
