Skip to content

Commit 38cb1da

Browse files
authored
Update azure-webapps-node.yml
1 parent 45003fc commit 38cb1da

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

.github/workflows/azure-webapps-node.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,61 @@ jobs:
1616
- uses: actions/checkout@v4
1717

1818
- name: Setup Node.js
19-
uses: actions/setup-node@v3
19+
uses: actions/setup-node@v4
2020
with:
2121
node-version: '20.x'
2222
cache: 'npm'
2323

24-
- name: Clean npm cache
25-
run: npm cache clean --force
26-
27-
- name: Delete lock file and reinstall
24+
- name: Clean npm cache and reinstall dependencies
2825
run: |
26+
npm cache clean --force
2927
rm -f package-lock.json
3028
npm install
3129
3230
- name: Build application
3331
run: npm run build
3432

35-
- name: Create production package.json
33+
- name: Prepare production deployment
3634
run: |
37-
cat > dist/package.json << EOF
35+
# Create deployment directory structure
36+
mkdir -p deployment
37+
38+
# Copy built application files
39+
cp -r dist/* deployment/
40+
41+
# Create a production package.json with serve as dependency
42+
cat > deployment/package.json << 'EOF'
3843
{
3944
"name": "porfolio-production",
4045
"version": "1.0.0",
41-
"type": "module",
46+
"engines": {
47+
"node": "20.x",
48+
"npm": "10.x"
49+
},
4250
"scripts": {
43-
"start": "npx serve -s . -l 0.0.0.0:\$PORT"
51+
"start": "serve -s . -p $PORT"
4452
},
4553
"dependencies": {
4654
"serve": "^14.2.4"
4755
}
4856
}
4957
EOF
5058
51-
- name: Install serve in dist directory
59+
- name: Install production dependencies
5260
run: |
53-
cd dist
54-
npm install
61+
cd deployment
62+
npm install --only=production --no-optional
63+
64+
# Verify serve is installed
65+
ls -la node_modules/.bin/
66+
echo "Checking serve installation:"
67+
npx serve --version || echo "Serve not found via npx"
5568
5669
- name: Upload artifact
5770
uses: actions/upload-artifact@v4
5871
with:
5972
name: node-app
60-
path: dist
73+
path: deployment
6174

6275
deploy:
6376
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)