Skip to content

Commit

Permalink
Fix CI GH action build Nextjs to GH Pages (#53)
Browse files Browse the repository at this point in the history
* update working directories

* unoptimized images in nextjs config to use default image loader

* add gh token
  • Loading branch information
toreylittlefield committed Sep 17, 2023
1 parent 91a540e commit d07e1f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,26 @@ 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.
restore-keys: |
${{ 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:
Expand All @@ -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 }}

3 changes: 3 additions & 0 deletions packages/client/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit d07e1f1

Please sign in to comment.