-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 2.06 KB
/
containerapp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: CI
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy to Azure
runs-on: ubuntu-latest
environment: prod_env
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
# Login to Azure container registry
- name: Login to Azure Container Registry
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# Build the image and push it to ACR
- name: Build the image and push it to ACR
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/minimal-api:v0.${{ github.run_number }} -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/minimal-api:latest
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/minimal-api:v0.${{ github.run_number }}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/minimal-api:latest
# Authenticate with the Azure CLI
- name: Login via Azure CLI
uses: Azure/login@v1
with:
creds: '{"clientId":"${{ secrets.ARM_CLIENT_ID }}","clientSecret":"${{ secrets.ARM_CLIENT_SECRET }}","subscriptionId":"${{ secrets.ARM_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.ARM_TENANT_ID }}"}'
# Update the container app with the new image tag
- name: Update the container app with the new image tag
run:
az containerapp update -n ${{ secrets.VAR_CAPP_NAME }} -g ${{ secrets.TF_VAR_rg_app }} --image ${{ secrets.REGISTRY_LOGIN_SERVER }}/minimal-api:latest --output none