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: Build and deploy Node.js app to Azure Web App - Chanet-Backend | |
| on: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js version | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '22.x' | |
| - name: npm install, build, and test | |
| working-directory: backend | |
| run: | | |
| npm install | |
| npm run build --if-present | |
| npm run test --if-present | |
| - name: Zip artifact for deployment (only backend folder) | |
| run: | | |
| cd backend | |
| zip -r ../release.zip . | |
| - name: Upload artifact for deployment job | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: node-app | |
| path: release.zip | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Download artifact from build job | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: node-app | |
| - name: Unzip artifact for deployment | |
| run: unzip release.zip | |
| - name: Login to Azure | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_C20414D818D7406C80CA259BCE691CDF }} | |
| tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_FC45F28160E84F3A8B745AF670AF1749 }} | |
| subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_C0F2ABB6863542148B40CDBEA9C4B3DD }} | |
| - name: Deploy to Azure Web App | |
| uses: azure/webapps-deploy@v3 | |
| with: | |
| app-name: 'Chanet-Backend' | |
| slot-name: 'Production' | |
| package: . |