Skip to content

Commit 62cdcf0

Browse files
Optimize GitHub Actions workflow and build script
- Update Node.js version to 20.x in workflow - Simplify npm cache verification and dependency caching - Remove explicit memory configuration in build.js - Delegate NODE_OPTIONS management to GitHub workflow - Improve workflow clarity and build process efficiency
1 parent 2dd5d5c commit 62cdcf0

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

.github/workflows/publish.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ jobs:
2525
- name: Setup Node.js ⚙️
2626
uses: actions/setup-node@v4
2727
with:
28-
# Use Node.js 18 to meet Next.js requirements
29-
node-version: '18.17.0'
28+
# Update Node.js version to meet Next.js requirements
29+
node-version: '20.x'
3030
cache: 'npm'
31+
cache-dependency-path: '**/package-lock.json'
3132

3233
- name: System information
3334
run: |
@@ -37,7 +38,7 @@ jobs:
3738
npm -v
3839
3940
- name: Install dependencies 📦
40-
run: npm ci --no-audit --prefer-offline
41+
run: npm ci --no-audit
4142

4243
- name: Install additional dependencies
4344
run: |
@@ -46,7 +47,7 @@ jobs:
4647
4748
- name: Optimize system for build
4849
run: |
49-
npm cache clean --force
50+
npm cache verify
5051
# Clear system caches to free up memory
5152
sudo sysctl -w vm.drop_caches=3
5253
# Increase swap space to handle memory pressure

build.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ fs.writeFileSync('.babelrc', JSON.stringify({
3838
// Set environment variables
3939
process.env.NODE_ENV = 'production';
4040
process.env.NEXT_TELEMETRY_DISABLED = '1';
41-
// Only use the max-old-space-size flag which is widely supported
42-
process.env.NODE_OPTIONS = '--max-old-space-size=4096';
4341

44-
// Add memory optimization flags for Next.js
42+
// Memory optimization flags for Next.js
4543
process.env.NEXT_MEMORY_OPTIMIZATION = 'true';
4644
process.env.NEXT_MINIMIZE_USAGE = 'true';
4745

@@ -52,8 +50,8 @@ if (process.env.GITHUB_PAGES) {
5250
// Run the build command with error handling
5351
try {
5452
console.log('Running Next.js build...');
55-
// Run with increased memory limit
56-
execSync('npx --no-install next build', {
53+
// Note: NODE_OPTIONS is set in the GitHub workflow file
54+
execSync('npx next build', {
5755
stdio: 'inherit',
5856
env: process.env,
5957
maxBuffer: 1024 * 1024 * 10 // Increase buffer size to 10MB

0 commit comments

Comments
 (0)