1- name : Build and Push Container
2-
3- on :
4- push :
5- branches : [ "main" ]
6- pull_request :
7- branches : [ "main" ]
8-
9- env :
10- REGISTRY : ghcr.io
11- IMAGE_NAME : ${{ github.repository_owner }}/copilotthatjawn
12-
13- jobs :
14- build-and-push :
15- runs-on : ubuntu-latest
16- permissions :
17- contents : read
18- id-token : write
19- packages : write
20-
21- steps :
22- - uses : actions/checkout@v4
23-
24- - name : Setup .NET
25- uses : actions/setup-dotnet@v3
26- with :
27- dotnet-version : ' 9.0.x'
28-
29- - name : Log in to GitHub Container Registry
30- uses : docker/login-action@v3
31- with :
32- registry : ${{ env.REGISTRY }}
33- username : ${{ github.actor }}
34- password : ${{ secrets.GITHUB_TOKEN }}
35-
36- - name : Extract metadata for container
37- id : meta
38- uses : docker/metadata-action@v5
39- with :
40- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41- tags : |
42- type=ref,event=branch
43- type=ref,event=pr
44- type=semver,pattern={{version}}
45- type=semver,pattern={{major}}.{{minor}}
46- type=semver,pattern={{major}}
47- type=sha
48-
49- - name : Set up Docker Buildx
50- uses : docker/setup-buildx-action@v3
51-
52- - name : Build and push container
53- uses : docker/build-push-action@v5
54- with :
55- context : .
56- push : true
57- tags : ${{ steps.meta.outputs.tags }}
58- labels : ${{ steps.meta.outputs.labels }}
59- cache-from : type=gha
60- cache-to : type=gha,mode=max
61-
62- # Deploy to Azure Container Apps
63- - name : Azure Login
64- uses : azure/login@v2
65- with :
66- client-id : ${{ secrets.CTJWEB_AZURE_CLIENT_ID }}
67- tenant-id : ${{ secrets.CTJWEB_AZURE_TENANT_ID }}
68- subscription-id : ${{ secrets.CTJWEB_AZURE_SUBSCRIPTION_ID }}
69- enable-AzPSSession : true
70-
71- - name : Deploy to Azure Container App
72- uses : azure/CLI@v2
73- with :
74- inlineScript : |
75- az config set extension.use_dynamic_install=yes_without_prompt
76- az containerapp update \
77- --name ctj-web \
78- --resource-group CopilotThatJawn \
79- --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${{ github.sha }}
0 commit comments