From d07e1f1fd3652def3b524def849b0c089598ec70 Mon Sep 17 00:00:00 2001 From: Torey Littlefield <52614742+toreylittlefield@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:35:00 +0800 Subject: [PATCH] Fix CI GH action build Nextjs to GH Pages (#53) * update working directories * unoptimized images in nextjs config to use default image loader * add gh token --- .github/workflows/nextjs.yml | 13 ++++++++++--- packages/client/next.config.js | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nextjs.yml b/.github/workflows/nextjs.yml index 109b958..83dbbae 100644 --- a/.github/workflows/nextjs.yml +++ b/.github/workflows/nextjs.yml @@ -64,8 +64,7 @@ jobs: - name: Restore cache uses: actions/cache@v3 with: - path: | - .next/cache + path: ./packages/client/.next/cache # Generate a new cache whenever packages or source files change. key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} # If source files changed but packages didn't, rebuild from a prior cache. @@ -73,14 +72,18 @@ jobs: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- - name: Install dependencies run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} + working-directory: ./packages/client - name: Build with Next.js run: ${{ steps.detect-package-manager.outputs.runner }} next build + working-directory: ./packages/client - name: Static HTML export with Next.js run: ${{ steps.detect-package-manager.outputs.runner }} next export + working-directory: ./packages/client - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: - path: ./out + name: client-artifact + path: ./packages/client/out # Deployment job deploy: @@ -93,3 +96,7 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2 + with: + local-dir: ./packages/client/out + token: ${{ secrets.GITHUB_TOKEN }} + diff --git a/packages/client/next.config.js b/packages/client/next.config.js index debc60b..fdb2eb8 100644 --- a/packages/client/next.config.js +++ b/packages/client/next.config.js @@ -4,6 +4,9 @@ const CopyPlugin = require('copy-webpack-plugin'); /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + images: { + unoptimized: true, // TODO: remove this when we have a proper image pipeline + }, webpack: (config) => { config.plugins.push( new CopyPlugin({