Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy More…
- User
Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Node.js app to Azure Web App - campus-safety
on: push: branches: - main workflow_dispatch:
jobs: build: runs-on: ubuntu-latest
steps: - uses: actions/checkout@v4 - name: Set up Node.js version uses: actions/setup-node@v3 with: node-version: "20.x" # Install dependencies - name: Install Node.js dependencies working-directory: ./server run: npm install # Run tests - name: Run tests working-directory: ./server run: npm test continue-on-error: true # Continue even if tests have non-zero exit code # Delete node_modules after tests - name: Clean up node_modules folder working-directory: ./server run: rm -rf node_modules # Zip artifact for deployment - name: Zip artifact for deployment run: zip release.zip ./* -r - name: Upload artifact for deployment job uses: actions/upload-artifact@v4 with: name: node-app path: release.zipdeploy: runs-on: ubuntu-latest needs: build environment: name: "Production" url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} permissions: id-token: write # This is required for requesting the JWT
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_C1C417C658644087A4BFB018CD1A6378 }} tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_9C9EA06695C44B6DA6CDC08A26468C61 }} subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_437A39D0CDFB47E1B35E3C4D4AC9E86C }} - name: Clean existing files in Azure Web App uses: azure/CLI@v1 with: inlineScript: | echo "Cleaning existing files in wwwroot..." az webapp run-command --name campus-safety --resource-group sdp --command-id 'bash' --script 'rm -rf /home/site/wwwroot/*' # Remove the zip file before deployment - name: Remove zip file run: rm release.zip - name: "Deploy to Azure Web App" id: deploy-to-webapp uses: azure/webapps-deploy@v3 with: app-name: "campus-safety" slot-name: "Production" package: .Starting script execution via docker image mcr.microsoft.com/azure-cli:2.64.0 Cleaning existing files in wwwroot... ERROR: 'run-command' is misspelled or not recognized by the system. Examples from AI knowledge base: https://aka.ms/cli_ref Read more about the command in reference docs Error: Error: az cli script failed. cleaning up container... MICROSOFT_AZURE_CLI_1728586220373_CONTAINER Error: az cli script failed.
- Assistant