From 481849456a2ba39154ed47541867f5ee865e0190 Mon Sep 17 00:00:00 2001 From: Josue JURE <57095041+josueJURE@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:50:37 +0000 Subject: [PATCH] Update azure-webapps-node.yml --- .github/workflows/azure-webapps-node.yml | 86 +++++++++++++----------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/.github/workflows/azure-webapps-node.yml b/.github/workflows/azure-webapps-node.yml index 642d476..3a8f0b0 100644 --- a/.github/workflows/azure-webapps-node.yml +++ b/.github/workflows/azure-webapps-node.yml @@ -19,12 +19,6 @@ - - - - - - name: Build and Deploy Node.js App to Azure on: @@ -44,41 +38,55 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - name: Install Dependencies - run: npm install - - name: Build Application - run: npm run build --if-present - - name: Test Application - run: npm run test --if-present - - name: Upload artifact for deployment job - uses: actions/upload-artifact@v3 - with: - name: node-app - path: . - + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Install Dependencies + run: npm install + + - name: Build Application + run: npm run build --if-present + + - name: Test Application + run: npm run test --if-present + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: node-app + path: . + deploy: permissions: - contents: none + contents: read + id-token: write # This is required for Azure login with OIDC runs-on: ubuntu-latest needs: build + environment: + name: 'production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + steps: - - name: Download artifact from build job - uses: actions/download-artifact@v3 - with: - name: node-app - - name: 'Login via Azure CLI' - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - name: 'Deploy to Azure WebApp' - uses: azure/webapps-deploy@v2 - with: - app-name: ${{ env.AZURE_WEBAPP_NAME }} - publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} - package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: node-app + + - name: Login to Azure + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: 'Deploy to Azure WebApp' + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}