Skip to content

Commit d46e0f9

Browse files
pnpm fix #4.
1 parent cedaaf4 commit d46e0f9

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

.github/workflows/nextjs-static-gh-pages.yml

+21-22
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,35 @@ jobs:
2626
id: detect-pm
2727
run: |
2828
if [ -f "pnpm-lock.yaml" ]; then
29-
echo "manager=pnpm" >> $GITHUB_OUTPUT
30-
echo "command=install" >> $GITHUB_OUTPUT
31-
echo "runner=pnpm exec" >> $GITHUB_OUTPUT
29+
echo "manager=pnpm" >> $GITHUB_ENV
30+
echo "command=install" >> $GITHUB_ENV
31+
echo "runner=pnpm exec" >> $GITHUB_ENV
3232
elif [ -f "yarn.lock" ]; then
33-
echo "manager=yarn" >> $GITHUB_OUTPUT
34-
echo "command=install" >> $GITHUB_OUTPUT
35-
echo "runner=yarn" >> $GITHUB_OUTPUT
33+
echo "manager=yarn" >> $GITHUB_ENV
34+
echo "command=install" >> $GITHUB_ENV
35+
echo "runner=yarn" >> $GITHUB_ENV
3636
else
37-
echo "manager=npm" >> $GITHUB_OUTPUT
38-
echo "command=ci" >> $GITHUB_OUTPUT
39-
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
37+
echo "manager=npm" >> $GITHUB_ENV
38+
echo "command=ci" >> $GITHUB_ENV
39+
echo "runner=npx --no-install" >> $GITHUB_ENV
4040
fi
4141
42+
# ✅ Explicitly Install pnpm before setting up Node.js
43+
- name: 📦 Install pnpm if needed
44+
if: env.manager == 'pnpm'
45+
run: npm install -g pnpm
46+
4247
- name: ⚙️ Setup Node.js
4348
uses: actions/setup-node@v4
4449
with:
4550
node-version: '20'
46-
cache: ${{ steps.detect-pm.outputs.manager }}
47-
48-
# Install pnpm if needed before verifying environment
49-
- name: 📦 Install Package Manager
50-
if: steps.detect-pm.outputs.manager == 'pnpm'
51-
run: npm install -g pnpm
51+
cache: ${{ env.manager }}
5252

5353
- name: 📝 Verify Environment
5454
run: |
5555
echo "Node.js $(node -v)"
5656
echo "npm $(npm -v)"
57-
${{ steps.detect-pm.outputs.manager }} --version
57+
${{ env.manager }} --version
5858
5959
- name: 🌐 Setup Pages
6060
uses: actions/configure-pages@v5
@@ -64,17 +64,16 @@ jobs:
6464
- name: 📦 Restore cache
6565
uses: actions/cache@v4
6666
with:
67-
path: |
68-
.next/cache
69-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
67+
path: .next/cache
68+
key: nextjs-${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}
7069
restore-keys: |
71-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-
70+
nextjs-${{ runner.os }}-
7271
7372
- name: 📥 Install dependencies
74-
run: ${{ steps.detect-pm.outputs.manager }} ${{ steps.detect-pm.outputs.command }}
73+
run: ${{ env.manager }} ${{ env.command }}
7574

7675
- name: 👷 Build with Next.js
77-
run: ${{ steps.detect-pm.outputs.runner }} next build
76+
run: ${{ env.runner }} next build
7877

7978
- name: 📤 Upload artifact
8079
uses: actions/upload-pages-artifact@v3

0 commit comments

Comments
 (0)