From 58a5a6456fb1c63b10bd9b5e3190f7ed47cfa2f3 Mon Sep 17 00:00:00 2001 From: Dave Skender <8432125+DaveSkender@users.noreply.github.com> Date: Thu, 22 Feb 2024 20:11:22 -0500 Subject: [PATCH] update deployer --- .github/workflows/deploy.yml | 19 ++++++++++++------- Server/WebApi/Program.cs | 4 +++- Server/WebApi/appsettings.Token.json | 19 ++++++++++--------- Server/WebApi/appsettings.json | 21 +++++++++++---------- docs/CONTRIBUTING.md | 1 - 5 files changed, 36 insertions(+), 28 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 56bffeed..c3002976 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,6 +12,7 @@ jobs: env: url: https://charts.stockindicators.dev + prv: ${{ vars.CLOUDFLARE_PREVIEW_URL }} steps: @@ -31,7 +32,8 @@ jobs: Copy-Item "appsettings.Token.json" -Destination "appsettings.json" -Force Remove-Item "appsettings.Token.json" -Force - (Get-Content appsettings.json).Replace("__Website__", "${{ env.url }}") | Set-Content appsettings.json + (Get-Content appsettings.json).Replace("__WebsiteUrl__", "${{ env.url }}") | Set-Content appsettings.json + (Get-Content appsettings.json).Replace("__PreviewUrl__", "${{ env.prv }}") | Set-Content appsettings.json Write-Host "... Done!" - name: Build .NET solution @@ -157,12 +159,15 @@ jobs: package: artifacts/api publish-profile: ${{ secrets.PUBLISH_PROFILE_API }} - - name: Deploy website - uses: azure/webapps-deploy@v2 - with: - app-name: stock-charts - package: artifacts/web - publish-profile: ${{ secrets.PUBLISH_PROFILE_WEB }} + - name: Publish to Cloudflare Pages + uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_KEY }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }} + gitHubToken: ${{ secrets.GITHUB_TOKEN }} + directory: artifacts/web + wranglerVersion: 'latest' - name: Define tag id: tag diff --git a/Server/WebApi/Program.cs b/Server/WebApi/Program.cs index 19c9d60d..53a83a4e 100644 --- a/Server/WebApi/Program.cs +++ b/Server/WebApi/Program.cs @@ -14,6 +14,7 @@ IConfigurationSection corsOrigins = configuration.GetSection("CorsOrigins"); List origins = []; origins.Add(item: corsOrigins["Website"]); +origins.Add(item: corsOrigins["Preview"]); // setup CORS for website services.AddCors(options => @@ -24,7 +25,8 @@ cors.AllowAnyHeader(); cors.AllowAnyMethod(); cors.AllowCredentials(); - cors.WithOrigins([.. origins]); + cors.WithOrigins([.. origins]) + .SetIsOriginAllowedToAllowWildcardSubdomains(); }); }); diff --git a/Server/WebApi/appsettings.Token.json b/Server/WebApi/appsettings.Token.json index 3cef0f51..1e69e787 100644 --- a/Server/WebApi/appsettings.Token.json +++ b/Server/WebApi/appsettings.Token.json @@ -1,12 +1,13 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "CorsOrigins": { - "Website": "__WebsiteUrl__" + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" } + }, + "CorsOrigins": { + "Website": "__WebsiteUrl__", + "Preview": "__PreviewUrl__" + } } diff --git a/Server/WebApi/appsettings.json b/Server/WebApi/appsettings.json index 988c7d04..6fa5c20d 100644 --- a/Server/WebApi/appsettings.json +++ b/Server/WebApi/appsettings.json @@ -1,13 +1,14 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*", - "CorsOrigins": { - "Website": "http://localhost:4200" + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" } + }, + "AllowedHosts": "*", + "CorsOrigins": { + "Website": "http://localhost:4200", + "Preview": "http://localhost:4200" + } } diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 4b2a9f61..fe30e36b 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -15,7 +15,6 @@ If you are reporting a bug, please submit an Issue with a detailed description o - Read this first: [contributing to an open-source GitHub project](https://codeburst.io/a-step-by-step-guide-to-making-your-first-github-contribution-5302260a2940) - Do not comingle multiple contributions. Please keep changes small and separate. -- The backlog for this demo project is [here](https://dev.azure.com/skender/Stock.Indicators/_boards/board/t/Stock.Charts). ## Testing