Skip to content

Commit

Permalink
added deploy workflow
Browse files Browse the repository at this point in the history
Update deploy workflow to use pnpm for package management

Remove Next.js static HTML export step
  • Loading branch information
gnehs committed Feb 21, 2024
1 parent d4d3bef commit 6895d07
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
78 changes: 78 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Deploy to GitHub Pages

on:
push:
branches: main
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
id: pnpm-store
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- name: Setup Pages
uses: actions/configure-pages@v4
with:
# Automatically inject basePath in your Next.js configuration file and disable
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next
- name: Restore cache
uses: actions/cache@v4
with:
path: |
.next/cache
${{ steps.pnpm-store.outputs.STORE_PATH }}
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Install dependencies
run: pnpm install
- name: Build with Next.js
run: pnpm next build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = { output: "export" };

export default nextConfig;

0 comments on commit 6895d07

Please sign in to comment.