refactor(web): ♻️ extract staging-web GH environment

This commit is contained in:
Collin Barrett 2024-06-13 15:43:46 -05:00
parent 6f8416ef84
commit 26c4ed2f8c
2 changed files with 40 additions and 11 deletions

View file

@ -16,23 +16,22 @@ on:
- web/**
jobs:
build_and_deploy_job:
name: Build and Deploy
build_and_deploy_staging:
name: Build & Deploy to Staging
runs-on: ubuntu-latest
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
if: github.event_name == 'pull_request' && github.event.action != 'closed'
# TODO: revise for stapp staging sites
environment:
name: production-web
url: https://filterlists.com
name: staging-web
url: ${{ steps.builddeploy.outputs.static_web_app_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build And Deploy
- name: Build & Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
@ -42,7 +41,31 @@ jobs:
app_location: "./web"
output_location: "build"
close_pull_request_job:
build_and_deploy_production:
name: Build & Deploy to Production
runs-on: ubuntu-latest
if: github.event_name == 'push'
environment:
name: production-web
url: https://filterlists.com
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build & Deploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_STAPP_FILTERLISTS_PROD }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "./web"
output_location: "build"
close_pull_request:
name: Close Pull Request
runs-on: ubuntu-latest
@ -51,7 +74,6 @@ jobs:
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_STAPP_FILTERLISTS_PROD }}

View file

@ -5,9 +5,16 @@
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCors(options => options.AddDefaultPolicy(policy =>
policy.WithOrigins("https://filterlists.com")
{
policy.SetIsOriginAllowed(origin =>
{
if (origin == "https://filterlists.com") return true;
return origin.StartsWith("https://nice-water-05873140f", StringComparison.InvariantCulture) &&
origin.EndsWith(".eastus2.5.azurestaticapps.net", StringComparison.InvariantCulture);
})
.WithMethods("GET")
.AllowAnyHeader()));
.AllowAnyHeader();
}));
builder.WebHost.ConfigureKestrel(serverOptions => serverOptions.AddServerHeader = false);
builder.AddServiceDefaults();
builder.Services.AddProblemDetails();