1+ name : Publish and Deploy WebApp
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ env :
9+ AZURE_WEBAPP_PACKAGE_PATH : .
10+ NODE_VERSION : 24
11+
12+ jobs :
13+ publish_WebApp :
14+ name : Publish Web App
15+ runs-on : ubuntu-latest
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - name : Use Node.js ${{ env.NODE_VERSION }}
20+ uses : actions/setup-node@v4
21+ with :
22+ node-version : ${{ env.NODE_VERSION }}
23+
24+ - name : npm install and build
25+ run : |
26+ npm i --workspaces=false
27+ working-directory : ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
28+
29+ - name : Cache .next/cache
30+ uses : actions/cache@v3
31+ env :
32+ cache-name : cache-node-modules
33+ with :
34+ path : ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/.next/cache
35+ key : nextjs | $(Agent.OS) | ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/package-lock.json
36+
37+ - name : Build
38+ run : npm run build --workspaces=false
39+ working-directory : ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
40+
41+ - name : Copy Static Assets
42+ run : |
43+ cp -r .next/static .next/standalone/.next/
44+ cp -r public .next/standalone/
45+ working-directory : ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
46+
47+ - name : Publish webapp artifact
48+ uses : actions/upload-artifact@v4
49+ with :
50+ path : ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/.next/standalone
51+ name : frontendwebapp
52+ include-hidden-files : true
53+
54+ # Deploy Production
55+ deploy-prod :
56+ name : Deploy to Appservice
57+ runs-on : ubuntu-latest
58+ environment : production
59+ needs :
60+ - publish_WebApp
61+ steps :
62+ - uses : actions/checkout@v4
63+
64+ - name : Download artifact from build job
65+ uses : actions/download-artifact@v4
66+ with :
67+ path : frontendwebapp
68+ name : frontendwebapp
69+
70+ - name : Deploy to Azure WebApp
71+ uses : azure/webapps-deploy@v2
72+ with :
73+ app-name : ${{ env.AZURE_WEBAPP_FRONTEND_NAME }}
74+ publish-profile : ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
75+ package : ${{ github.workspace }}/frontendwebapp
0 commit comments