name: Build and deploy to Netlify
on:
  push:
    branches:
      - master
jobs:
  generate-site:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: cachix/install-nix-action@v17
        with:
          nix_path: nixpkgs=channel:nixos-unstable
      - name: Setup for static site generation
        run: |
          nix develop
          mv notebook/ site/public/
          cd site
          npm install
          npm run build
      - name: Deploy to Netlify
        uses: nwtgck/actions-netlify@v1.2
        with:
          publish-dir: ./site/out
          production-branch: master
          production-deploy: ${{ github.ref_name == 'master' }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
          deploy-message: "Deploy from GitHub Actions"
          enable-pull-request-comment: true
          enable-commit-comment: true
          enable-commit-status: true
          overwrites-pull-request-comment: false
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}