1919
2020
2121
22-
23-
24-
25-
26-
27-
2822name : Build and Deploy Node.js App to Azure
2923
3024on :
@@ -44,41 +38,55 @@ jobs:
4438 build :
4539 runs-on : ubuntu-latest
4640 steps :
47- - uses : actions/checkout@v4
48- - name : Set up Node.js
49- uses : actions/setup-node@v3
50- with :
51- node-version : ${{ env.NODE_VERSION }}
52- cache : ' npm'
53- - name : Install Dependencies
54- run : npm install
55- - name : Build Application
56- run : npm run build --if-present
57- - name : Test Application
58- run : npm run test --if-present
59- - name : Upload artifact for deployment job
60- uses : actions/upload-artifact@v3
61- with :
62- name : node-app
63- path : .
64-
41+ - uses : actions/checkout@v4
42+
43+ - name : Set up Node.js
44+ uses : actions/setup-node@v4
45+ with :
46+ node-version : ${{ env.NODE_VERSION }}
47+ cache : ' npm'
48+
49+ - name : Install Dependencies
50+ run : npm install
51+
52+ - name : Build Application
53+ run : npm run build --if-present
54+
55+ - name : Test Application
56+ run : npm run test --if-present
57+
58+ - name : Upload artifact for deployment job
59+ uses : actions/upload-artifact@v4
60+ with :
61+ name : node-app
62+ path : .
63+
6564 deploy :
6665 permissions :
67- contents : none
66+ contents : read
67+ id-token : write # This is required for Azure login with OIDC
6868 runs-on : ubuntu-latest
6969 needs : build
70+ environment :
71+ name : ' production'
72+ url : ${{ steps.deploy-to-webapp.outputs.webapp-url }}
73+
7074 steps :
71- - name : Download artifact from build job
72- uses : actions/download-artifact@v3
73- with :
74- name : node-app
75- - name : ' Login via Azure CLI'
76- uses : azure/login@v1
77- with :
78- creds : ${{ secrets.AZURE_CREDENTIALS }}
79- - name : ' Deploy to Azure WebApp'
80- uses : azure/webapps-deploy@v2
81- with :
82- app-name : ${{ env.AZURE_WEBAPP_NAME }}
83- publish-profile : ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
84- package : ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
75+ - name : Download artifact from build job
76+ uses : actions/download-artifact@v4
77+ with :
78+ name : node-app
79+
80+ - name : Login to Azure
81+ uses : azure/login@v1
82+ with :
83+ client-id : ${{ secrets.AZURE_CLIENT_ID }}
84+ tenant-id : ${{ secrets.AZURE_TENANT_ID }}
85+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
86+
87+ - name : ' Deploy to Azure WebApp'
88+ id : deploy-to-webapp
89+ uses : azure/webapps-deploy@v3
90+ with :
91+ app-name : ${{ env.AZURE_WEBAPP_NAME }}
92+ package : ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
0 commit comments