Skip to content

Update azure-webapps-node.yml #10

Update azure-webapps-node.yml

Update azure-webapps-node.yml #10

name: Deploy React (Vite) App to Azure Web App
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Install serve globally for production
run: npm install -g serve
- name: Create production package.json
run: |
cat > package.json << EOF
{
"name": "porfolio-production",
"version": "1.0.0",
"type": "module",
"scripts": {
"start": "npx serve -s dist -l 0.0.0.0:\$PORT"
},
"dependencies": {
"serve": "^14.2.4"
}
}
EOF
- name: Install production dependencies
run: npm install --production
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: node-app
path: |
dist
package.json
node_modules
deploy:
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write
contents: read
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: node-app
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_646B290AC1724693B164CD3D4947B353 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BD250A8452F0421B94ECF3BD50BFDC47 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_A0A3E69559D143F8A11E4E6CD7432251 }}
- name: Deploy to Azure
uses: azure/webapps-deploy@v3
with:
app-name: 'albertoruiz'
slot-name: 'Production'
package: .