Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI-CD for domains #930

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,63 @@ jobs:
environment: production
image-tag: ${{ needs.build_image.outputs.docker-image-tag }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}

deploy_domains_infra:
name: Deploy Domains Infrastructure
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
concurrency: deploy_production
needs: [deploy_production]
environment:
name: production
permissions:
id-token: write

steps:
- 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 Domains Infrastructure
id: deploy_domains_infra
uses: DFE-Digital/github-actions/deploy-domains-infra@master
with:
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

deploy_domains_env:
name: Deploy Domains to ${{ matrix.domain_environment }} environment
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
concurrency: deploy_${{ matrix.domain_environment }}
needs: [deploy_domains_infra]
strategy:
max-parallel: 1
matrix:
domain_environment: [test, preprod, production]
environment:
name: production
permissions:
id-token: write

steps:
- 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 Domains Environment
id: deploy_domains_env
uses: DFE-Digital/github-actions/deploy-domains-env@master
with:
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
environment: ${{ matrix.domain_environment }}
healthcheck: health
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ get-cluster-credentials: set-azure-account ## Get AKS cluster credentials
.PHONY: vendor-domain-infra-modules
vendor-domain-infra-modules:
rm -rf terraform/domains/infrastructure/vendor/modules/domains
TERRAFORM_MODULES_TAG=stable
$(eval include global_config/domains.sh)
git -c advice.detachedHead=false clone --depth=1 --single-branch --branch ${TERRAFORM_MODULES_TAG} https://github.com/DFE-Digital/terraform-modules.git terraform/domains/infrastructure/vendor/modules/domains

domains-infra-init: domains composed-variables vendor-domain-infra-modules set-azure-account
Expand Down
1 change: 1 addition & 0 deletions global_config/domains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ AZURE_SUBSCRIPTION=s189-teacher-services-cloud-production
AZURE_RESOURCE_PREFIX=s189p01
CONFIG_SHORT=dom
DISABLE_KEYVAULTS=true
TERRAFORM_MODULES_TAG=stable
10 changes: 10 additions & 0 deletions terraform/domains/environment_domains/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
output "external_urls" {
value = flatten([
for zone_name, zone_values in var.hosted_zone : [
for domain in zone_values["domains"] : (domain == "apex" ?
"https://${zone_name}" :
"https://${domain}.${zone_name}"
)
]
])
}
Loading