Skip to content

Commit 22b1b99

Browse files
authored
Update azure-webapps-node.yml
1 parent d45a2ff commit 22b1b99

File tree

1 file changed

+26
-37
lines changed

1 file changed

+26
-37
lines changed

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

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,82 +9,71 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
permissions:
13-
contents: read
14-
1512
steps:
1613
- uses: actions/checkout@v4
17-
14+
1815
- name: Setup Node.js
1916
uses: actions/setup-node@v4
2017
with:
21-
node-version: '20.x'
18+
node-version: '18.x' # Match Azure App Service Node version
2219
cache: 'npm'
23-
24-
- name: Clean npm cache
25-
run: npm cache clean --force
26-
27-
- name: Delete lock file and reinstall
20+
21+
- name: Install dependencies and build
2822
run: |
29-
rm -f package-lock.json
30-
npm install
31-
32-
- name: Build application
33-
run: npm run build
34-
35-
- name: Create production package.json
23+
npm ci
24+
npm run build
25+
26+
- name: Create production package.json for Azure
3627
run: |
3728
cat > dist/package.json << 'EOF'
3829
{
3930
"name": "porfolio-production",
4031
"version": "1.0.0",
4132
"engines": {
42-
"node": "20.x",
43-
"npm": "10.x"
33+
"node": "18.x",
34+
"npm": "9.x"
4435
},
4536
"scripts": {
46-
"start": "serve -s . -p ${PORT:-8080}"
37+
"start": "serve -s . -p $PORT"
4738
},
4839
"dependencies": {
4940
"serve": "^14.2.4"
5041
}
5142
}
5243
EOF
53-
54-
- name: Install serve in dist directory
44+
45+
- name: Install production dependencies
5546
run: |
5647
cd dist
5748
npm install --only=production
58-
49+
50+
# Verify installation works like in SSH
51+
echo "Verifying serve installation:"
52+
npx serve --version
53+
echo "Testing serve command syntax:"
54+
timeout 5s npm start || echo "Serve test completed successfully"
55+
5956
- name: Upload artifact
6057
uses: actions/upload-artifact@v4
6158
with:
62-
name: node-app
59+
name: webapp
6360
path: dist
6461

6562
deploy:
6663
runs-on: ubuntu-latest
6764
needs: build
68-
permissions:
69-
id-token: write
70-
contents: read
71-
7265
steps:
73-
- name: Download artifact
74-
uses: actions/download-artifact@v4
66+
- uses: actions/download-artifact@v4
7567
with:
76-
name: node-app
77-
78-
- name: Login to Azure
79-
uses: azure/login@v2
68+
name: webapp
69+
70+
- uses: azure/login@v2
8071
with:
8172
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_646B290AC1724693B164CD3D4947B353 }}
8273
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BD250A8452F0421B94ECF3BD50BFDC47 }}
8374
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_A0A3E69559D143F8A11E4E6CD7432251 }}
8475

85-
- name: Deploy to Azure
86-
uses: azure/webapps-deploy@v3
76+
- uses: azure/webapps-deploy@v3
8777
with:
8878
app-name: 'albertoruiz'
89-
slot-name: 'Production'
9079
package: .

0 commit comments

Comments
 (0)