Skip to content

Commit e0a22d8

Browse files
committed
Update nextjs.yml
1 parent 7448c1a commit e0a22d8

1 file changed

Lines changed: 20 additions & 58 deletions

File tree

.github/workflows/nextjs.yml

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,45 @@
1-
# Sample workflow for building and deploying a Next.js site to GitHub Pages
2-
#
3-
# To get started with Next.js see: https://nextjs.org/docs/getting-started
4-
#
5-
name: Deploy Next.js site to Pages
1+
# Inspired from https://github.com/actions/starter-workflows/blob/main/pages/nextjs.yml
2+
name: GitHub Pages
63

74
on:
8-
# Runs on pushes targeting the default branch
95
push:
10-
branches: ["master"]
11-
12-
# Allows you to run this workflow manually from the Actions tab
6+
branches: main
137
workflow_dispatch:
148

15-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
169
permissions:
1710
contents: read
1811
pages: write
1912
id-token: write
2013

21-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2314
concurrency:
24-
group: "pages"
15+
group: 'pages'
2516
cancel-in-progress: false
2617

2718
jobs:
28-
# Build job
2919
build:
3020
runs-on: ubuntu-latest
3121
steps:
32-
- name: Checkout
33-
uses: actions/checkout@v4
34-
- name: Detect package manager
35-
id: detect-package-manager
36-
run: |
37-
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
38-
echo "manager=yarn" >> $GITHUB_OUTPUT
39-
echo "command=install" >> $GITHUB_OUTPUT
40-
echo "runner=yarn" >> $GITHUB_OUTPUT
41-
exit 0
42-
elif [ -f "${{ github.workspace }}/package.json" ]; then
43-
echo "manager=npm" >> $GITHUB_OUTPUT
44-
echo "command=ci" >> $GITHUB_OUTPUT
45-
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
46-
exit 0
47-
else
48-
echo "Unable to determine package manager"
49-
exit 1
50-
fi
51-
- name: Setup Node
52-
uses: actions/setup-node@v4
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-node@v4
5324
with:
54-
node-version: "20"
55-
cache: ${{ steps.detect-package-manager.outputs.manager }}
56-
- name: Setup Pages
25+
node-version: '20'
26+
cache: yarn
27+
- id: configurepages
5728
uses: actions/configure-pages@v5
58-
# with:
59-
# Automatically inject basePath in your Next.js configuration file and disable
60-
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
61-
#
62-
# You may remove this line if you want to manage the configuration yourself.
63-
# static_site_generator: next
6429
- name: Restore cache
6530
uses: actions/cache@v4
6631
with:
67-
path: |
68-
.next/cache
69-
# Generate a new cache whenever packages or source files change.
70-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
71-
# If source files changed but packages didn't, rebuild from a prior cache.
32+
path: .next/cache
33+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
7234
restore-keys: |
73-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
74-
- name: Install dependencies
75-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
76-
- name: Build with Next.js
77-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
78-
- name: Upload artifact
79-
uses: actions/upload-pages-artifact@v2
35+
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
36+
- run: yarn
37+
- run: yarn build
38+
env:
39+
EXPORT: 1
40+
UNOPTIMIZED: 1
41+
BASE_PATH: ${{ steps.configurepages.outputs.base_path }}
42+
- uses: actions/upload-pages-artifact@v3
8043
with:
8144
path: ./out
8245

@@ -88,6 +51,5 @@ jobs:
8851
runs-on: ubuntu-latest
8952
needs: build
9053
steps:
91-
- name: Deploy to GitHub Pages
92-
id: deployment
54+
- id: deployment
9355
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)