Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Move website to Cloudflare Pages #315

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:

env:
url: https://charts.stockindicators.dev
prv: ${{ vars.CLOUDFLARE_PREVIEW_URL }}

steps:

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Server/WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
IConfigurationSection corsOrigins = configuration.GetSection("CorsOrigins");
List<string> origins = [];
origins.Add(item: corsOrigins["Website"]);
origins.Add(item: corsOrigins["Preview"]);

// setup CORS for website
services.AddCors(options =>
Expand All @@ -24,7 +25,8 @@
cors.AllowAnyHeader();
cors.AllowAnyMethod();
cors.AllowCredentials();
cors.WithOrigins([.. origins]);
cors.WithOrigins([.. origins])
.SetIsOriginAllowedToAllowWildcardSubdomains();
});
});

Expand Down
19 changes: 10 additions & 9 deletions Server/WebApi/appsettings.Token.json
Original file line number Diff line number Diff line change
@@ -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__"
}
}
21 changes: 11 additions & 10 deletions Server/WebApi/appsettings.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
1 change: 0 additions & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading