name: Deploy storybook to Github pages

on:
    push:
        branches: [main]
    # Allows you to run this workflow manually from the Actions tab
    workflow_dispatch:

jobs:
    build:
        runs-on: ubuntu-latest

        steps:
            - uses: actions/checkout@v2

            - name: Read .nvmrc
              run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
              id: nvm

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

            - name: install
              run: npm ci

            - name: build
              run: npm run build

            - name: storybook:build
              run: npm run storybook:build

            - name: Deploy to Github pages
              uses: JamesIves/github-pages-deploy-action@3.7.1
              with:
                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
                  BRANCH: gh-pages
                  FOLDER: storybook-static
