1818# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples
1919
2020
21-
22-
23-
24-
25-
26-
27-
2821name : Build and Deploy Node.js App to Azure
2922
3023on :
@@ -44,41 +37,61 @@ jobs:
4437 build :
4538 runs-on : ubuntu-latest
4639 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-
40+ - uses : actions/checkout@v4
41+
42+ - name : Set up Node.js
43+ uses : actions/setup-node@v4
44+ with :
45+ node-version : ${{ env.NODE_VERSION }}
46+ cache : ' npm'
47+
48+ - name : Install Dependencies
49+ run : npm install
50+
51+ - name : Build Application
52+ run : npm run build --if-present
53+
54+ - name : Test Application
55+ run : npm run test --if-present
56+
57+ - name : Upload artifact for deployment job
58+ uses : actions/upload-artifact@v4
59+ with :
60+ name : node-app
61+ path : .
62+
6563 deploy :
6664 permissions :
67- contents : none
65+ contents : read
66+ id-token : write # This is required for Azure login with OIDC
6867 runs-on : ubuntu-latest
6968 needs : build
69+ environment :
70+ name : ' production'
71+ url : ${{ steps.deploy-to-webapp.outputs.webapp-url }}
72+
7073 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 }}
74+ - name : Download artifact from build job
75+ uses : actions/download-artifact@v4
76+ with :
77+ name : node-app
78+
79+ - name : Login to Azure
80+ uses : azure/login@v1
81+ with :
82+ client-id : ${{ secrets.AZURE_CLIENT_ID }}
83+ tenant-id : ${{ secrets.AZURE_TENANT_ID }}
84+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
85+
86+ - name : ' Deploy to Azure WebApp'
87+ id : deploy-to-webapp
88+ uses : azure/webapps-deploy@v3
89+ with :
90+ app-name : ${{ env.AZURE_WEBAPP_NAME }}
91+ package : ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
92+
93+
94+
95+
96+
97+
0 commit comments