Improve SEO #30
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | name: Deploy React (Vite) App to Azure Web App | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| # Add explicit permissions for Azure OIDC | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Clean install dependencies | |
| run: | | |
| npm cache clean --force | |
| rm -f package-lock.json | |
| rm -rf node_modules | |
| npm install | |
| - name: Build application | |
| run: npm run build | |
| - name: Create production package.json for Azure | |
| run: | | |
| cat > dist/package.json << 'EOF' | |
| { | |
| "name": "porfolio-production", | |
| "version": "1.0.0", | |
| "engines": { | |
| "node": "20.x", | |
| "npm": "10.x" | |
| }, | |
| "scripts": { | |
| "start": "node server.js" | |
| }, | |
| "dependencies": { | |
| "express": "^4.18.2", | |
| "compression": "^1.7.4" | |
| } | |
| } | |
| EOF | |
| - name: Copy server.js to dist | |
| run: cp server.js dist/ | |
| - name: Install production dependencies | |
| run: | | |
| cd dist | |
| npm install --only=production | |
| # Verify express installation | |
| echo "Verifying express installation:" | |
| ls -la node_modules/express/ | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: webapp | |
| path: dist | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: webapp | |
| - 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 Web App | |
| uses: azure/webapps-deploy@v3 | |
| with: | |
| app-name: 'albertoruiz' | |
| slot-name: 'Production' | |
| package: . |