Build and deploy backend with unique image tagging using commit SHA

This commit is contained in:
faris Aljohari
2024-07-22 19:53:26 +03:00
parent 4d966feaba
commit e96e6db34d

View File

@ -11,7 +11,7 @@ env:
AZURE_WEB_APP_SLOT_NAME: 'dev'
ACR_REGISTRY: 'syncrow.azurecr.io'
IMAGE_NAME: 'backend'
IMAGE_TAG: 'latest'
IMAGE_TAG: '${{ github.sha }}' # Use commit SHA for unique tagging
jobs:
build_and_deploy:
@ -25,10 +25,13 @@ jobs:
with:
node-version: '20'
- name: Install dependencies and build project
- name: Clear npm cache and install dependencies
run: |
npm cache clean --force
npm install
npm run build
- name: Build project
run: npm run build
- name: Log in to Azure
uses: azure/login@v1
@ -52,4 +55,7 @@ jobs:
--name ${{ env.AZURE_WEB_APP_NAME }} \
--resource-group backend \
--docker-custom-image-name ${{ env.ACR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
--docker-registry-server-url https://${{ env.ACR_REGISTRY }}
--docker-registry-server-url https://${{ env.ACR_REGISTRY }}
- name: Restart Web App
run: az webapp restart --name ${{ env.AZURE_WEB_APP_NAME }} --resource-group backend