Add GitHub Pages and SWA to STS CSP trusted domains #9
This file contains hidden or 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: Deploy IdentityServer to Azure App Service | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - 'TokenService/Duende-IdentityServer/**' | |
| - '.github/workflows/deploy-identityserver.yml' | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write # Required for OIDC token request | |
| contents: read | |
| env: | |
| DOTNET_VERSION: '8.x' | |
| STS_PROJECT_PATH: 'TokenService/Duende-IdentityServer/src/DuendeIdentityServer.STS.Identity/DuendeIdentityServer.STS.Identity.csproj' | |
| ADMIN_PROJECT_PATH: 'TokenService/Duende-IdentityServer/src/DuendeIdentityServer.Admin/DuendeIdentityServer.Admin.csproj' | |
| STS_PUBLISH_DIR: '${{ github.workspace }}/publish/ids' | |
| ADMIN_PUBLISH_DIR: '${{ github.workspace }}/publish/admin' | |
| APP_SERVICE_NAME: 'app-talent-ids-dev' | |
| ADMIN_APP_SERVICE_NAME: 'app-talent-admin-dev' | |
| RESOURCE_GROUP: 'rg-talent-dev' | |
| jobs: | |
| build-and-deploy: | |
| name: Build and Deploy IdentityServer | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository (with submodules) | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up .NET ${{ env.DOTNET_VERSION }} | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Restore dependencies | |
| run: | | |
| dotnet restore ${{ env.STS_PROJECT_PATH }} | |
| dotnet restore ${{ env.ADMIN_PROJECT_PATH }} | |
| - name: Build | |
| run: | | |
| dotnet build ${{ env.STS_PROJECT_PATH }} --configuration Release --no-restore | |
| dotnet build ${{ env.ADMIN_PROJECT_PATH }} --configuration Release --no-restore | |
| - name: Publish STS | |
| run: | | |
| dotnet publish ${{ env.STS_PROJECT_PATH }} \ | |
| --configuration Release \ | |
| --no-build \ | |
| --output ${{ env.STS_PUBLISH_DIR }} | |
| - name: Publish Admin | |
| run: | | |
| dotnet publish ${{ env.ADMIN_PROJECT_PATH }} \ | |
| --configuration Release \ | |
| --no-build \ | |
| --output ${{ env.ADMIN_PUBLISH_DIR }} | |
| - name: Log in 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: Configure STS App Service settings | |
| env: | |
| IDS_CONN: ${{ secrets.IDS_DB_CONNECTION_STRING }} | |
| IDS_URL: ${{ secrets.IDENTITY_SERVER_URL }} | |
| ADMIN_URL: ${{ secrets.IDENTITY_ADMIN_URL }} | |
| run: | | |
| az webapp config appsettings set \ | |
| --resource-group ${{ env.RESOURCE_GROUP }} \ | |
| --name ${{ env.APP_SERVICE_NAME }} \ | |
| --settings \ | |
| "ConnectionStrings__ConfigurationDbConnection=$IDS_CONN" \ | |
| "ConnectionStrings__PersistedGrantDbConnection=$IDS_CONN" \ | |
| "ConnectionStrings__IdentityDbConnection=$IDS_CONN" \ | |
| "ConnectionStrings__DataProtectionDbConnection=$IDS_CONN" \ | |
| "AdminConfiguration__IdentityServerBaseUrl=$IDS_URL" \ | |
| "AdminConfiguration__IdentityAdminBaseUrl=$ADMIN_URL" \ | |
| "CspTrustedDomains__0=www.gravatar.com" \ | |
| "CspTrustedDomains__1=fonts.googleapis.com" \ | |
| "CspTrustedDomains__2=fonts.gstatic.com" \ | |
| "CspTrustedDomains__3=workcontrolgit.github.io" \ | |
| "CspTrustedDomains__4=mango-flower-0ced4011e.4.azurestaticapps.net" \ | |
| "ASPNETCORE_ENVIRONMENT=Production" | |
| - name: Configure Admin App Service settings | |
| env: | |
| IDS_CONN: ${{ secrets.IDS_DB_CONNECTION_STRING }} | |
| IDS_URL: ${{ secrets.IDENTITY_SERVER_URL }} | |
| ADMIN_URL: ${{ secrets.IDENTITY_ADMIN_URL }} | |
| run: | | |
| az webapp config appsettings set \ | |
| --resource-group ${{ env.RESOURCE_GROUP }} \ | |
| --name ${{ env.ADMIN_APP_SERVICE_NAME }} \ | |
| --settings \ | |
| "ConnectionStrings__ConfigurationDbConnection=$IDS_CONN" \ | |
| "ConnectionStrings__PersistedGrantDbConnection=$IDS_CONN" \ | |
| "ConnectionStrings__IdentityDbConnection=$IDS_CONN" \ | |
| "ConnectionStrings__AdminLogDbConnection=$IDS_CONN" \ | |
| "ConnectionStrings__AdminAuditLogDbConnection=$IDS_CONN" \ | |
| "ConnectionStrings__DataProtectionDbConnection=$IDS_CONN" \ | |
| "AdminConfiguration__IdentityServerBaseUrl=$IDS_URL" \ | |
| "AdminConfiguration__IdentityAdminRedirectUri=$ADMIN_URL/signin-oidc" \ | |
| "SeedConfiguration__ApplySeed=false" \ | |
| "DatabaseMigrationsConfiguration__ApplyDatabaseMigrations=false" \ | |
| "ASPNETCORE_ENVIRONMENT=Production" | |
| - name: Deploy STS to Azure App Service | |
| uses: azure/webapps-deploy@v3 | |
| with: | |
| app-name: ${{ env.APP_SERVICE_NAME }} | |
| package: ${{ env.STS_PUBLISH_DIR }} | |
| - name: Deploy Admin to Azure App Service | |
| uses: azure/webapps-deploy@v3 | |
| with: | |
| app-name: ${{ env.ADMIN_APP_SERVICE_NAME }} | |
| package: ${{ env.ADMIN_PUBLISH_DIR }} |