-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (71 loc) · 2.93 KB
/
deploy-image.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Deploy Image to Environment
on:
workflow_call:
inputs:
environment:
type: string
required: true
branch:
type: string
required: true
checked-out-sha:
type: string
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.environment }}
cancel-in-progress: true
env:
GCR_DOCKER_IMAGE: sts-content-and-support
ACR_DOCKER_IMAGE: content-support-app
GITHUB_CONTAINER_REGISTRY: ghcr.io
ORG_NAME: dfe-digital
jobs:
pull-image-from-gcr-and-publish-to-acr:
runs-on: ubuntu-22.04
name: Pull Image From GitHub Container Registry and Publish to Azure Container Registry
environment: ${{ inputs.environment }}
steps:
- name: GitHub Container Registry Login
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_CONTAINER_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull Image From GCR
run: docker pull ${{ env.GITHUB_CONTAINER_REGISTRY }}/${{ env.ORG_NAME }}/${{ env.GCR_DOCKER_IMAGE }}:${{ inputs.branch }}-${{ inputs.checked-out-sha }}
- name: Azure Container Registry Login
uses: docker/login-action@v3
with:
registry: ${{ secrets.AZ_ACR_URL }}
username: ${{ secrets.AZ_CLIENT_ID }}
password: ${{ secrets.AZ_CLIENT_SECRET }}
- name: Push Image To ACR
run: |
docker tag ${{ env.GITHUB_CONTAINER_REGISTRY }}/${{ env.ORG_NAME }}/${{ env.GCR_DOCKER_IMAGE }}:${{ inputs.branch }}-${{ inputs.checked-out-sha }} ${{ secrets.AZ_ACR_URL }}/${{ env.ACR_DOCKER_IMAGE }}:${{ inputs.branch }}-${{ inputs.checked-out-sha }}-${{ inputs.environment }}
docker push ${{ secrets.AZ_ACR_URL }}/${{ env.ACR_DOCKER_IMAGE }}:${{ inputs.branch }}-${{ inputs.checked-out-sha }}-${{ inputs.environment }}
deploy-image:
runs-on: ubuntu-22.04
name: Deploy Image To ${{ inputs.environment }}
environment: ${{ inputs.environment }}
needs: [pull-image-from-gcr-and-publish-to-acr]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Azure CLI Login
uses: ./.github/actions/azure-login
with:
az_tenant_id: ${{ secrets.AZ_TENANT_ID }}
az_subscription_id: ${{ secrets.AZ_SUBSCRIPTION_ID }}
az_client_id: ${{ secrets.AZ_CLIENT_ID }}
az_client_secret: ${{ secrets.AZ_CLIENT_SECRET }}
- name: Update Azure Container Apps Revision
uses: azure/CLI@v1
id: azure
with:
azcliversion: 2.61.0
inlineScript: |
az containerapp update \
--name ${{ secrets.AZ_ACA_NAME }} \
--resource-group ${{ secrets.AZ_ACA_RESOURCE_GROUP }} \
--image ${{ secrets.AZ_ACR_URL }}/${{ env.ACR_DOCKER_IMAGE }}:${{ inputs.branch }}-${{ inputs.checked-out-sha }}-${{ inputs.environment }} \