name: Build and Deploy to GitHub Pages on: push: branches: - main workflow_dispatch: jobs: build-and-deploy: permissions: contents: read pages: read runs-on: ubuntu-latest steps: - name: Git Checkout uses: actions/checkout@v3.3.0 with: ref: main - name: Setup Pages uses: actions/configure-pages@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version-file: '.nvmrc' cache: 'npm' - name: Install NPM packages run: npm ci - uses: jongwooo/gatsby-cache@v1.4.1 with: key: github-pages-gatsby-ubuntu-latest - name: Build Gatsby run: npm run build-ci env: PATH_PREFIX: nodejs.dev/ - name: Upload Website to Pages uses: actions/upload-pages-artifact@v1 with: path: './public' deploy: permissions: pages: write id-token: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest needs: build-and-deploy steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v1