Skip to content

Commit d45a2ff

Browse files
authored
Update azure-webapps-node.yml3
1 parent 5e26d6e commit d45a2ff

File tree

1 file changed

+60
-13
lines changed

1 file changed

+60
-13
lines changed
Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,90 @@
1-
name: Simple Azure Deploy
1+
name: Deploy React (Vite) App to Azure Web App
22

33
on:
4+
push:
5+
branches:
6+
- main
47
workflow_dispatch:
58

69
jobs:
710
build:
811
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
915
steps:
1016
- uses: actions/checkout@v4
11-
- uses: actions/setup-node@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
1220
with:
1321
node-version: '20.x'
14-
15-
- name: Install and build
22+
cache: 'npm'
23+
24+
- name: Clean npm cache
25+
run: npm cache clean --force
26+
27+
- name: Delete lock file and reinstall
1628
run: |
29+
rm -f package-lock.json
1730
npm install
18-
npm run build
19-
20-
- name: Upload files
31+
32+
- name: Build application
33+
run: npm run build
34+
35+
- name: Create production package.json
36+
run: |
37+
cat > dist/package.json << 'EOF'
38+
{
39+
"name": "porfolio-production",
40+
"version": "1.0.0",
41+
"engines": {
42+
"node": "20.x",
43+
"npm": "10.x"
44+
},
45+
"scripts": {
46+
"start": "serve -s . -p ${PORT:-8080}"
47+
},
48+
"dependencies": {
49+
"serve": "^14.2.4"
50+
}
51+
}
52+
EOF
53+
54+
- name: Install serve in dist directory
55+
run: |
56+
cd dist
57+
npm install --only=production
58+
59+
- name: Upload artifact
2160
uses: actions/upload-artifact@v4
2261
with:
23-
name: webapp
62+
name: node-app
2463
path: dist
2564

2665
deploy:
2766
runs-on: ubuntu-latest
2867
needs: build
68+
permissions:
69+
id-token: write
70+
contents: read
71+
2972
steps:
30-
- uses: actions/download-artifact@v4
73+
- name: Download artifact
74+
uses: actions/download-artifact@v4
3175
with:
32-
name: webapp
33-
34-
- uses: azure/login@v2
76+
name: node-app
77+
78+
- name: Login to Azure
79+
uses: azure/login@v2
3580
with:
3681
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_646B290AC1724693B164CD3D4947B353 }}
3782
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BD250A8452F0421B94ECF3BD50BFDC47 }}
3883
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_A0A3E69559D143F8A11E4E6CD7432251 }}
3984

40-
- uses: azure/webapps-deploy@v3
85+
- name: Deploy to Azure
86+
uses: azure/webapps-deploy@v3
4187
with:
4288
app-name: 'albertoruiz'
89+
slot-name: 'Production'
4390
package: .

0 commit comments

Comments
 (0)