Skip to content

App Gateway

App Gateway #1016

Workflow file for this run

name: App Gateway
on:
push:
branches:
- main
paths:
- "application/*"
- "application/shared-kernel/**"
- "application/AppGateway/**"
- ".github/workflows/app-gateway.yml"
- ".github/workflows/_deploy-container.yml"
- "!**.md"
pull_request:
paths:
- "application/*"
- "application/shared-kernel/**"
- "application/AppGateway/**"
- ".github/workflows/app-gateway.yml"
- ".github/workflows/_deploy-container.yml"
- "!**.md"
workflow_dispatch:
concurrency:
group: app-gateway-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.generate_version.outputs.version }}
deploy_staging: ${{ steps.determine_deployment.outputs.deploy_staging }}
deploy_production: ${{ steps.determine_deployment.outputs.deploy_production }}
steps:
- name: Checkout Code
uses: actions/checkout@v7
- name: Generate Version
id: generate_version
run: |
# Zero-padded so versions sort lexicographically and clock-time is unambiguous (e.g. 0904, not 94)
VERSION=$(date +"%Y.%m.%d.%H%M")
echo "Generated version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Determine Deployment Conditions
id: determine_deployment
run: |
deploy_staging="${{ github.ref == 'refs/heads/main' && vars.STAGING_CLUSTER_ENABLED == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Deploy to Staging')) }}"
echo "deploy_staging=$deploy_staging" >> $GITHUB_OUTPUT
deploy_production="${{ github.ref == 'refs/heads/main' && vars.PRODUCTION_CLUSTER1_ENABLED == 'true' }}"
echo "deploy_production=$deploy_production" >> $GITHUB_OUTPUT
- name: Setup Node.js Environment
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install Node Modules
working-directory: application
run: npm ci
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v5
with:
global-json-file: application/global.json
- name: Restore .NET Tools
working-directory: application
run: dotnet tool restore
- name: Restore .NET Dependencies
working-directory: application
run: dotnet restore
- name: Generate and Set User Secret for Token Signing Key
working-directory: application/shared-kernel/SharedKernel
run: |
# Extract UserSecretsId from the .csproj file
USER_SECRETS_ID=$(grep -oP '(?<=<UserSecretsId>).*?(?=</UserSecretsId>)' SharedKernel.csproj)
# Generate a 512-bit key and set it as a user secret that can be use for token signing when running tests
dotnet user-secrets set "authentication-token-signing-key" "$(openssl rand -base64 64)" --id $USER_SECRETS_ID
- name: Run Tests
working-directory: application
run: |
dotnet build AppGateway.Tests/AppGateway.Tests.csproj --no-restore &&
dotnet test AppGateway.Tests/AppGateway.Tests.csproj --no-build
- name: Build Backend Solution
if: ${{ steps.determine_deployment.outputs.deploy_staging == 'true' }}
working-directory: application
run: |
dotnet build PlatformPlatform.slnx --no-restore /p:Version=${{ steps.generate_version.outputs.version }} /p:DeploymentCommitHash=${{ github.event.pull_request.head.sha || github.sha }} /p:DeploymentGithubActionId=${{ github.run_id }}
- name: Publish Build
if: ${{ steps.determine_deployment.outputs.deploy_staging == 'true' }}
working-directory: application
run: |
dotnet publish ./AppGateway/AppGateway.csproj --configuration Release --no-restore --output ./AppGateway/publish /p:Version=${{ steps.generate_version.outputs.version }} /p:DeploymentCommitHash=${{ github.event.pull_request.head.sha || github.sha }} /p:DeploymentGithubActionId=${{ github.run_id }}
- name: Save Artifacts
if: ${{ steps.determine_deployment.outputs.deploy_staging == 'true' }}
uses: actions/upload-artifact@v7
with:
name: app-gateway
path: application/AppGateway/publish/**/*
api-stage:
name: Staging
if: ${{ needs.build-and-test.outputs.deploy_staging == 'true' }}
needs: build-and-test
uses: ./.github/workflows/_deploy-container.yml
secrets: inherit
with:
image_name: app-gateway
version: ${{ needs.build-and-test.outputs.version }}
artifacts_name: app-gateway
artifacts_path: application/AppGateway/publish
docker_context: ./application
docker_file: ./AppGateway/Dockerfile
azure_environment: "stage"
cluster_location_acronym: ${{ vars.STAGING_CLUSTER_LOCATION_ACRONYM }}
service_principal_id: ${{ vars.STAGING_SERVICE_PRINCIPAL_ID }}
subscription_id: ${{ vars.STAGING_SUBSCRIPTION_ID }}
api-prod1:
name: Production
if: ${{ needs.build-and-test.outputs.deploy_production == 'true' }}
needs: [build-and-test, api-stage]
uses: ./.github/workflows/_deploy-container.yml
secrets: inherit
with:
image_name: app-gateway
version: ${{ needs.build-and-test.outputs.version }}
artifacts_name: app-gateway
artifacts_path: application/AppGateway/publish
docker_context: ./application
docker_file: ./AppGateway/Dockerfile
azure_environment: "prod"
cluster_location_acronym: ${{ vars.PRODUCTION_CLUSTER1_LOCATION_ACRONYM }}
service_principal_id: ${{ vars.PRODUCTION_SERVICE_PRINCIPAL_ID }}
subscription_id: ${{ vars.PRODUCTION_SUBSCRIPTION_ID }}