Skip to content

Added Authentication #32

Added Authentication

Added Authentication #32

name: Gateway API Release
on:
push:
branches: [main]
paths:
- "src/Gateway/**"
- "src/Defaults/**"
- ".github/workflows/deploy-gateway.yml"
- "Directory.Packages.props"
workflow_dispatch: {}
jobs:
build-publish-deploy:
runs-on: ubuntu-latest
concurrency:
group: deploy-gateway
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Azure login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: ACR login (for dotnet publish push)
uses: docker/login-action@v3
with:
registry: ${{ secrets.ACR_LOGIN_SERVER }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Compute image tag
id: meta
run: |
TS=$(date -u +'%Y%m%dT%H%M%SZ')
SHORTSHA=${GITHUB_SHA::7}
echo "tag=${TS}-${SHORTSHA}" >> $GITHUB_OUTPUT
echo "image=${{ secrets.ACR_LOGIN_SERVER }}/ccc-eu1-demo-ca-gateway:${TS}-${SHORTSHA}" >> $GITHUB_OUTPUT
# Build .NET app and publish directly to an OCI image, then push to ACR.
- name: dotnet publish -> container (push to ACR)
working-directory: src/Gateway
run: |
dotnet restore
dotnet publish -c Release \
-p:ContainerRepository=ccc-eu1-demo-ca-gateway \
-p:ContainerImageTag=${{ steps.meta.outputs.tag }} \
-p:ContainerRegistry=${{ secrets.ACR_LOGIN_SERVER }} \
-p:PublishAot=true \
-p:RuntimeIdentifier=linux-x64
- name: Create or Update App Service
run: |
# Create the web app if it doesn't exist
if ! az webapp show --name ccc-eu1-demo-ca-gateway --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} &> /dev/null; then
echo "Creating new App Service: ccc-eu1-demo-ca-gateway"
az webapp create \
--name ccc-eu1-demo-ca-gateway \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--plan ${{ secrets.APP_SERVICE_PLAN }} \
--deployment-container-image-name ${{ steps.meta.outputs.image }}
fi
# Configure container settings
az webapp config container set \
--name ccc-eu1-demo-ca-gateway \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--container-image-name ${{ steps.meta.outputs.image }} \
--container-registry-url https://${{ secrets.ACR_LOGIN_SERVER }} \
--container-registry-user ${{ secrets.ACR_USERNAME }} \
--container-registry-password ${{ secrets.ACR_PASSWORD }}
# Configure the exposed port
az webapp config appsettings set \
--name ccc-eu1-demo-ca-gateway \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--settings WEBSITES_PORT=8080
# Enable continuous deployment from ACR
az webapp deployment container config \
--name ccc-eu1-demo-ca-gateway \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--enable-cd true
# Restart the app to apply changes
az webapp restart \
--name ccc-eu1-demo-ca-gateway \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }}