This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (99 loc) · 4.17 KB
/
cms.yaml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: CMS deployment
concurrency: cms
on:
workflow_dispatch:
push:
branches:
- main
paths:
- ".github/workflows/**"
- "infrastructure/**"
- "cms/**"
permissions:
id-token: write
jobs:
deploy_infra:
name: Deploy infrastructure
runs-on: ubuntu-latest
environment: postgres
outputs:
containerRegistryName: ${{ steps.deployinfra.outputs.containerRegistryName }}
containerRegistryLoginServer: ${{ steps.deployinfra.outputs.containerRegistryLoginServer }}
resourceGroupName: ${{ steps.deployinfra.outputs.resourceGroupName }}
resourceLocation: ${{ steps.deployinfra.outputs.resourceLocation }}
logAnalyticsWorkspaceName: ${{ steps.deployinfra.outputs.logAnalyticsWorkspaceName }}
keyVaultName: ${{ steps.deployinfra.outputs.keyVaultName }}
identityName: ${{ steps.deployinfra.outputs.identityName }}
steps:
- uses: actions/checkout@v4
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy infrastructure
id: deployinfra
uses: azure/arm-deploy@v2
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
scope: "subscription"
template: ./infrastructure/cms/infrastructure.bicep
parameters: "environment=postgres"
region: ${{ vars.AZURE_REGION }}
push_images_to_acr:
name: Push Docker images to Azure Container Registry
runs-on: ubuntu-latest
needs: [deploy_infra]
steps:
- uses: actions/checkout@v4
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Login to the container registry
uses: azure/docker-login@v2
with:
login-server: ${{ needs.deploy_infra.outputs.containerRegistryLoginServer }}
username: ${{ secrets.AZURE_CLIENT_ID }}
password: ${{ secrets.AZURE_CLIENT_SECRET }}
- name: Build and push CMS image
run: |
docker build . -t ${{ needs.deploy_infra.outputs.containerRegistryLoginServer }}/cms:latest -f ./infrastructure/cms/Dockerfile.cms
docker push ${{ needs.deploy_infra.outputs.containerRegistryLoginServer }}/cms:latest
- name: Build and push Create SQL User image
run: |
docker build . -t ${{ needs.deploy_infra.outputs.containerRegistryLoginServer }}/cms/init:latest -f ./infrastructure/cms/Dockerfile.init
docker push ${{ needs.deploy_infra.outputs.containerRegistryLoginServer }}/cms/init:latest
deploy_cms:
name: Deploy CMS applications
runs-on: ubuntu-latest
environment: postgres
needs: [deploy_infra, push_images_to_acr]
steps:
- uses: actions/checkout@v4
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy CMS application
id: deploycms
uses: azure/arm-deploy@v2
with:
scope: "resourcegroup"
resourceGroupName: ${{ needs.deploy_infra.outputs.resourceGroupName }}
template: ./infrastructure/cms/main.bicep
parameters: >
databaseClient=${{ vars.CMS_DATABASE_CLIENT }}
logAnalyticsWorkspaceName=${{ needs.deploy_infra.outputs.logAnalyticsWorkspaceName }}
keyVaultName=${{ needs.deploy_infra.outputs.keyVaultName }}
registryName=${{ needs.deploy_infra.outputs.containerRegistryName }}
identityName=${{ needs.deploy_infra.outputs.identityName }}
cmsImageName=${{ needs.deploy_infra.outputs.containerRegistryLoginServer }}/cms:latest
cmsInitImageName=${{ needs.deploy_infra.outputs.containerRegistryLoginServer }}/cms/init:latest
databaseName=${{ vars.CMS_DATABASE_NAME }}
region: ${{ vars.AZURE_REGION }}