This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
allowing Azure services to MySQL firewall #88
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: production | |
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=production" | |
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: production | |
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 | |
region: ${{ vars.AZURE_REGION }} |