Here is my CI CD pipeline to build and push the next js web app to Azure Web App Service.
Current pipeline literally takes 30 minutes to be precise for deployment. Most of the time is for deployment.
Build -> 3min. 20 sec.
Deploy -> 26min. 37 sec.
I am not able to figure out how to solve this issue of zipping and deploying the package. In prior times i have done directly to VM’s using PM2 and it was super quick. Need help to speed it up for Azure Web Apps.
name: Build and deploy Node.js app to Azure Web App - name
on:
push:
branches:
- staging
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_HOST: ${{ secrets.NEXT_PUBLIC_HOST }}
NEXT_PUBLIC_REDIRECT_URL: ${{ secrets.NEXT_PUBLIC_REDIRECT_URL }}
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: npm install, build, and test
run: |
npm install
npm run build
- name: Zip artifact for deployment
run: zip -r release.zip .next/ * -x "*.git*"
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: node-app
path: release.zip
deploy:
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: Unzip artifact for deployment
run: unzip release.zip
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'nextstaging'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_F1C1 }}
package: .