Skip to content

Commit a963774

Browse files
Merge pull request #6 from techboy-coder/dev
change package manager to pnpm
2 parents d8feb9d + 1d39e5d commit a963774

File tree

1 file changed

+75
-75
lines changed

1 file changed

+75
-75
lines changed

.github/workflows/nextjs.yml

+75-75
Original file line numberDiff line numberDiff line change
@@ -5,89 +5,89 @@
55
name: Deploy Next.js site to Pages
66

77
on:
8-
# Runs on pushes targeting the default branch
9-
push:
10-
branches: ["main"]
8+
# Runs on pushes targeting the default branch
9+
push:
10+
branches: ["main"]
1111

12-
# Allows you to run this workflow manually from the Actions tab
13-
workflow_dispatch:
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
1414

1515
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1616
permissions:
17-
contents: read
18-
pages: write
19-
id-token: write
17+
contents: read
18+
pages: write
19+
id-token: write
2020

2121
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
2222
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2323
concurrency:
24-
group: "pages"
25-
cancel-in-progress: false
24+
group: "pages"
25+
cancel-in-progress: false
2626

2727
jobs:
28-
# Build job
29-
build:
30-
runs-on: ubuntu-latest
31-
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
53-
with:
54-
node-version: "20"
55-
cache: ${{ steps.detect-package-manager.outputs.manager }}
56-
- name: Setup Pages
57-
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
64-
- name: Restore cache
65-
uses: actions/cache@v4
66-
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.
72-
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@v3
80-
with:
81-
path: ./out
28+
# Build job
29+
build:
30+
runs-on: ubuntu-latest
31+
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=pnpm" >> $GITHUB_OUTPUT
44+
echo "command=ci" >> $GITHUB_OUTPUT
45+
echo "runner=pnpx --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
53+
with:
54+
node-version: "20"
55+
cache: ${{ steps.detect-package-manager.outputs.manager }}
56+
- name: Setup Pages
57+
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
64+
- name: Restore cache
65+
uses: actions/cache@v4
66+
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.
72+
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@v3
80+
with:
81+
path: ./out
8282

83-
# Deployment job
84-
deploy:
85-
environment:
86-
name: github-pages
87-
url: ${{ steps.deployment.outputs.page_url }}
88-
runs-on: ubuntu-latest
89-
needs: build
90-
steps:
91-
- name: Deploy to GitHub Pages
92-
id: deployment
93-
uses: actions/deploy-pages@v4
83+
# Deployment job
84+
deploy:
85+
environment:
86+
name: github-pages
87+
url: ${{ steps.deployment.outputs.page_url }}
88+
runs-on: ubuntu-latest
89+
needs: build
90+
steps:
91+
- name: Deploy to GitHub Pages
92+
id: deployment
93+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)