1+ name : Frontend - Build and Deploy on Azure
2+
3+ on :
4+ push :
5+ branches : [ development ]
6+ paths :
7+ - ' frontend/**'
8+ - ' .github/workflows/azure-deploy-frontend-dev.yml'
9+ workflow_dispatch :
10+
11+ env :
12+ REGISTRY : ghcr.io
13+ FRONTEND_IMAGE_NAME : ${{ github.repository }}-frontend-dev
14+
15+ jobs :
16+ build-and-push :
17+ runs-on : ubuntu-latest
18+ permissions :
19+ contents : read
20+ packages : write
21+ outputs :
22+ short_sha : ${{ steps.extract-sha.outputs.short_sha }}
23+
24+ steps :
25+ - name : Checkout repository
26+ uses : actions/checkout@v4
27+
28+ - name : Extract short SHA
29+ id : extract-sha
30+ run : |
31+ SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
32+ echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
33+ echo "Using short SHA: $SHORT_SHA"
34+
35+ - name : Log in to GitHub Container Registry
36+ uses : docker/login-action@v3
37+ with :
38+ registry : ${{ env.REGISTRY }}
39+ username : ${{ github.actor }}
40+ password : ${{ secrets.GITHUB_TOKEN }}
41+
42+ - name : Extract Docker metadata
43+ id : meta
44+ uses : docker/metadata-action@v5
45+ with :
46+ images : ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}
47+ tags : |
48+ type=sha,format=short
49+ type=ref,event=branch
50+ latest
51+
52+ - name : Build and push Docker image
53+ uses : docker/build-push-action@v6
54+ with :
55+ context : ./frontend
56+ file : ./frontend/Dockerfile
57+ push : true
58+ tags : ${{ steps.meta.outputs.tags }}
59+ labels : ${{ steps.meta.outputs.labels }}
60+
61+ deploy :
62+ needs : build-and-push
63+ runs-on : ubuntu-latest
64+ environment : production
65+
66+ steps :
67+ - name : Azure login
68+ uses : azure/login@v2
69+ with :
70+ creds : ${{ secrets.AZURE_CREDENTIALS }}
71+
72+ - name : Deploy to Azure Container Apps
73+ id : deploy
74+ uses : azure/container-apps-deploy-action@v2
75+ with :
76+ registryUrl : ${{ env.REGISTRY }}
77+ registryUsername : ${{ github.actor }}
78+ registryPassword : ${{ secrets.GHCR_PASS }}
79+ containerAppName : mploy-frontend-dev
80+ resourceGroup : ${{ secrets.AZURE_RESOURCE_GROUP }}
81+ imageToDeploy : ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:sha-${{ needs.build-and-push.outputs.short_sha }}
82+ targetPort : 3000
0 commit comments