From 99a5712c27407a59e63afca07721f32e7323ae64 Mon Sep 17 00:00:00 2001 From: Jack Edwards Date: Tue, 31 Dec 2024 16:03:24 -0600 Subject: [PATCH] Switch 'dev' to 'stage' --- .github/workflows/build-and-push-api.yml | 2 +- .github/workflows/build-and-push-web.yml | 3 ++- .github/workflows/deploy-to-environment.yml | 8 ++++---- Crypter.Web/wwwroot/appsettings.Staging.json | 11 +++++++++++ Crypter.Web/wwwroot/js/blazorStartup.js | 10 +++++++--- 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 Crypter.Web/wwwroot/appsettings.Staging.json diff --git a/.github/workflows/build-and-push-api.yml b/.github/workflows/build-and-push-api.yml index 74fbc285f..a9a23ab49 100644 --- a/.github/workflows/build-and-push-api.yml +++ b/.github/workflows/build-and-push-api.yml @@ -13,7 +13,7 @@ on: type: choice options: - production - - development + - staging env: registry: ghcr.io/${{ github.repository_owner }} diff --git a/.github/workflows/build-and-push-web.yml b/.github/workflows/build-and-push-web.yml index 5558a4fef..1ab4d31ab 100644 --- a/.github/workflows/build-and-push-web.yml +++ b/.github/workflows/build-and-push-web.yml @@ -13,7 +13,7 @@ on: type: choice options: - production - - development + - staging env: registry: ghcr.io/${{ github.repository_owner }} @@ -37,6 +37,7 @@ jobs: working-directory: ${{ env.project_root }} run: | sed -i 's|${API_BASE_URL}|${{ vars.API_BASE_URL }}|g' wwwroot/appsettings.json + sed -i 's|${API_BASE_URL}|${{ vars.API_BASE_URL }}|g' wwwroot/appsettings.Development.json - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/.github/workflows/deploy-to-environment.yml b/.github/workflows/deploy-to-environment.yml index 60b3aec78..d378d26a9 100644 --- a/.github/workflows/deploy-to-environment.yml +++ b/.github/workflows/deploy-to-environment.yml @@ -9,10 +9,10 @@ on: type: choice options: - production - - development + - staging env: - docker_compose_profile: ${{ (github.event.inputs.environment == 'development' && 'local') || 'web' }} + docker_compose_profile: ${{ (github.event.inputs.environment == 'staging' && 'local') || 'web' }} jobs: deploy-web-container: @@ -68,8 +68,8 @@ jobs: source: docker-compose.yml target: crypter-web-container/ - - name: Push latest Docker Compose override file if deploying to Development server - if: github.event.inputs.environment == 'development' + - name: Push latest Docker Compose override file if deploying to Staging server + if: github.event.inputs.environment == 'staging' uses: appleboy/scp-action@v0.1.7 with: host: ${{ secrets.APPSERVER_SSH_HOST }} diff --git a/Crypter.Web/wwwroot/appsettings.Staging.json b/Crypter.Web/wwwroot/appsettings.Staging.json new file mode 100644 index 000000000..703718263 --- /dev/null +++ b/Crypter.Web/wwwroot/appsettings.Staging.json @@ -0,0 +1,11 @@ +{ + "ApiSettings": { + "ApiBaseUrl": "${API_BASE_URL}" + }, + "Logging": { + "LogLevel": { + "Default": "Debug", + "Microsoft.AspNetCore": "Information" + } + } +} diff --git a/Crypter.Web/wwwroot/js/blazorStartup.js b/Crypter.Web/wwwroot/js/blazorStartup.js index 349c5e4bd..789dfc293 100644 --- a/Crypter.Web/wwwroot/js/blazorStartup.js +++ b/Crypter.Web/wwwroot/js/blazorStartup.js @@ -1,5 +1,9 @@ +const environmentMap = { + "localhost": "Development", + "stage.crypter.dev": "Staging", + "www.crypter.dev": "Production" +} + Blazor.start({ - environment: window.location.hostname === "localhost" - ? "Development" - : "Production" + environment: environmentMap[window.location.hostname] }); \ No newline at end of file