diff --git a/.github/workflows/deploy-env.yaml b/.github/workflows/deploy-env.yaml index abcbaa4..5143306 100644 --- a/.github/workflows/deploy-env.yaml +++ b/.github/workflows/deploy-env.yaml @@ -7,34 +7,34 @@ on: workflow_dispatch: jobs: -# package: -# name: 'Package Web in Docker' -# runs-on: ubuntu-latest -# defaults: -# run: -# working-directory: ./src -# permissions: -# contents: read -# packages: write -# -# steps: -# - uses: actions/checkout@v4 -# -# - name: Lowercase the repo name and username -# run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} -# -# - name: Build Web Docker Image -# run: | -# docker build . -t ghcr.io/${{ env.REPO }}:${{ github.sha }} -f web/CareLeavers.Web/Dockerfile -# -# - uses: docker/login-action@v1 -# with: -# registry: ghcr.io -# username: ${{ github.actor }} -# password: ${{ secrets.GITHUB_TOKEN }} -# -# - name: Push Web Docker Image -# run: docker push ghcr.io/${{ env.REPO }}:${{ github.sha }} + package: + name: 'Package Web in Docker' + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./src + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - name: Lowercase the repo name and username + run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + + - name: Build Web Docker Image + run: | + docker build . -t ghcr.io/${{ env.REPO }}:${{ github.sha }} -f web/CareLeavers.Web/Dockerfile + + - uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push Web Docker Image + run: docker push ghcr.io/${{ env.REPO }}:${{ github.sha }} # # terraform_dependencies: # name: 'Provision Terraform Dependencies' @@ -112,52 +112,52 @@ jobs: working-directory: ./src/infrastructure/terraform run: terraform apply plan.plan -# deploy-backend: -# name: Deploy Web -# permissions: -# contents: none -# id-token: write -# runs-on: ubuntu-latest -# needs: [ package, deploy_infrastructure ] -# environment: -# name: 'Test' -# -# steps: -# - name: Lowercase the repo name and username -# run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} -# -# - name: 'Az CLI login' -# uses: azure/login@v1 -# with: -# creds: | -# { -# "clientId": "${{ secrets.AZURE_CLIENT_ID }}", -# "clientSecret": "${{ secrets.AZURE_CLIENT_SECRET }}", -# "tenantId": "${{ secrets.AZURE_TENANT_ID }}", -# "subscriptionId": "${{ secrets.AZURE_SUBSCRIPTION_ID }}" -# } -# -# - name: 'Get publishing profile' -# run: | -# publishingProfile=$(az webapp deployment list-publishing-profiles --name s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-app-service --slot staging --resource-group s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-rg --xml) -# echo "PUBLISHING_PROFILE=$publishingProfile" >>${GITHUB_ENV} -# -# - name: Deploy to Azure Web App -# id: deploy-to-webapp -# uses: azure/webapps-deploy@v2 -# with: -# app-name: ${{ vars.DEV_AZURE_WEBAPP_NAME }} -# slot-name: 'staging' -# publish-profile: ${{ env.PUBLISHING_PROFILE }} -# images: 'ghcr.io/${{ env.REPO }}:${{ github.sha }}' -# -# - name: Wait for Staging to warm up -# id: wait-for-staging -# uses: jtalk/url-health-check-action@v4 -# with: -# url: https://s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-fd.azurefd.net/staging-health -# retry-delay: 3s -# max-attempts: 5 -# -# - name: Swap slot to production -# run: az webapp deployment slot swap --name s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-app-service --resource-group s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-rg --slot staging --target-slot production + deploy-backend: + name: Deploy Web + permissions: + contents: none + id-token: write + runs-on: ubuntu-latest + needs: [ package, deploy_infrastructure ] + environment: + name: 'Test' + + steps: + - name: Lowercase the repo name and username + run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + + - name: 'Az CLI login' + uses: azure/login@v1 + with: + creds: | + { + "clientId": "${{ secrets.AZURE_CLIENT_ID }}", + "clientSecret": "${{ secrets.AZURE_CLIENT_SECRET }}", + "tenantId": "${{ secrets.AZURE_TENANT_ID }}", + "subscriptionId": "${{ secrets.AZURE_SUBSCRIPTION_ID }}" + } + + - name: 'Get publishing profile' + run: | + publishingProfile=$(az webapp deployment list-publishing-profiles --name s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-app-service --slot staging --resource-group s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-rg --xml) + echo "PUBLISHING_PROFILE=$publishingProfile" >>${GITHUB_ENV} + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ vars.DEV_AZURE_WEBAPP_NAME }} + slot-name: 'staging' + publish-profile: ${{ env.PUBLISHING_PROFILE }} + images: 'ghcr.io/${{ env.REPO }}:${{ github.sha }}' + + - name: Wait for Staging to warm up + id: wait-for-staging + uses: jtalk/url-health-check-action@v4 + with: + url: https://s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-fd.azurefd.net/staging-health + retry-delay: 3s + max-attempts: 5 + + - name: Swap slot to production + run: az webapp deployment slot swap --name s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-app-service --resource-group s186${{ vars.ENVIRONMENT_PREFIX }}-cl-web-rg --slot staging --target-slot production diff --git a/src/infrastructure/terraform/frontdoor.tf b/src/infrastructure/terraform/frontdoor.tf index cb9a9f8..5b6c415 100644 --- a/src/infrastructure/terraform/frontdoor.tf +++ b/src/infrastructure/terraform/frontdoor.tf @@ -9,6 +9,7 @@ resource "azurerm_cdn_frontdoor_profile" "frontdoor-web-profile" { name = "${local.service_prefix}-web-fd-profile" resource_group_name = azurerm_resource_group.web-rg.name sku_name = "Standard_AzureFrontDoor" + tags = local.common_tags } resource "azurerm_cdn_frontdoor_origin_group" "frontdoor-origin-group" {