Skip to content

Commit 33b20c8

Browse files
Added pnpm bug fix + comments & icons & debugging output.
1 parent e91532b commit 33b20c8

File tree

1 file changed

+43
-33
lines changed

1 file changed

+43
-33
lines changed
Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,106 @@
1-
name: Deploy Next.js site to Pages
1+
name: 🐙 Deploy Next.js to GitHub Pages
22

33
on:
4-
# Runs on pushes targeting the default branch
54
push:
65
branches: ['main']
7-
8-
# Allows you to run this workflow manually from the Actions tab
96
workflow_dispatch:
107

11-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
128
permissions:
139
contents: read
1410
pages: write
1511
id-token: write
1612

17-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
1913
concurrency:
2014
group: 'pages'
2115
cancel-in-progress: false
2216

2317
jobs:
24-
# Build job
2518
build:
19+
name: 🛠️ Build Next.js
2620
runs-on: ubuntu-latest
2721
steps:
28-
- name: Checkout
22+
# Checkout code
23+
- name: 🔍 Checkout repository
2924
uses: actions/checkout@v4
3025

31-
- name: Detect package manager
32-
id: detect-package-manager
26+
# Detect package manager
27+
- name: 🔎 Detect package manager
28+
id: detect-pm
3329
run: |
34-
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
35-
echo "manager=yarn" >> $GITHUB_OUTPUT
36-
echo "command=install" >> $GITHUB_OUTPUT
37-
echo "runner=yarn" >> $GITHUB_OUTPUT
38-
elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
30+
echo "🔍 Scanning for package manager..."
31+
if [ -f "pnpm-lock.yaml" ]; then
32+
echo "✅ Found pnpm lockfile"
3933
echo "manager=pnpm" >> $GITHUB_OUTPUT
4034
echo "command=install" >> $GITHUB_OUTPUT
4135
echo "runner=pnpm exec" >> $GITHUB_OUTPUT
42-
elif [ -f "${{ github.workspace }}/package.json" ]; then
36+
elif [ -f "yarn.lock" ]; then
37+
echo "✅ Found yarn lockfile"
38+
echo "manager=yarn" >> $GITHUB_OUTPUT
39+
echo "command=install" >> $GITHUB_OUTPUT
40+
echo "runner=yarn" >> $GITHUB_OUTPUT
41+
elif [ -f "package.json" ]; then
42+
echo "ℹ️ Using npm as fallback"
4343
echo "manager=npm" >> $GITHUB_OUTPUT
4444
echo "command=ci" >> $GITHUB_OUTPUT
4545
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
4646
else
47-
echo "Unable to determine package manager"
47+
echo "❌ No package manager detected!"
4848
exit 1
4949
fi
5050
51-
- name: Setup Node
51+
# Setup Node.js with automatic package manager installation
52+
- name: ⚙️ Setup Node.js
5253
uses: actions/setup-node@v4
5354
with:
5455
node-version: '20'
55-
cache: ${{ steps.detect-package-manager.outputs.manager }}
56+
cache: ${{ steps.detect-pm.outputs.manager }}
57+
package-manager: ${{ steps.detect-pm.outputs.manager }}
58+
59+
# Debugging step to verify installations
60+
- name: 📝 Check versions
61+
run: |
62+
echo "Node.js $(node -v)"
63+
echo "npm $(npm -v)"
64+
${{ steps.detect-pm.outputs.manager }} --version
5665
57-
- name: Setup Pages
66+
# Configure GitHub Pages
67+
- name: 🌐 Setup Pages
5868
uses: actions/configure-pages@v5
5969
with:
60-
# Automatically inject basePath in your Next.js configuration file and disable
61-
# server side image optimization.
6270
static_site_generator: next
6371

64-
- name: Restore cache
72+
# Cache management
73+
- name: 📦 Restore cache
6574
uses: actions/cache@v4
6675
with:
6776
path: |
6877
.next/cache
69-
# Generate a new cache whenever packages or source files change.
7078
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
71-
# If source files changed but packages didn't, rebuild from a prior cache.
7279
restore-keys: |
7380
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-
7481
75-
- name: Install dependencies
76-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
82+
# Install dependencies
83+
- name: 📥 Install dependencies
84+
run: ${{ steps.detect-pm.outputs.manager }} ${{ steps.detect-pm.outputs.command }}
7785

78-
- name: Build with Next.js
79-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
86+
# Build project
87+
- name: 👷 Build with Next.js
88+
run: ${{ steps.detect-pm.outputs.runner }} next build
8089

81-
- name: Upload artifact
90+
# Upload artifact
91+
- name: 📤 Upload artifact
8292
uses: actions/upload-pages-artifact@v3
8393
with:
8494
path: ./out
8595

86-
# Deployment job
8796
deploy:
97+
name: 🚀 Deploy to GitHub Pages
8898
environment:
8999
name: github-pages
90100
url: ${{ steps.deployment.outputs.page_url }}
91101
runs-on: ubuntu-latest
92102
needs: build
93103
steps:
94-
- name: Deploy to GitHub Pages
104+
- name: 🌍 Deploy to GitHub Pages
95105
id: deployment
96106
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)