Skip to content

feat: add PR preview deployments via Azure Static Web Apps#65

Merged
chrisjwalk-bot merged 3 commits into
mainfrom
feat/swa-preview-64
Mar 15, 2026
Merged

feat: add PR preview deployments via Azure Static Web Apps#65
chrisjwalk-bot merged 3 commits into
mainfrom
feat/swa-preview-64

Conversation

@chrisjwalk-bot
Copy link
Copy Markdown
Collaborator

Closes #64

What

Adds automatic preview deployments for every PR using Azure Static Web Apps (free tier), so UI changes can be reviewed without running the app locally.

How it works

  • Angular preview build uses environment.preview.ts (via fileReplacements) which sets apiBaseUrl to the production App Service URL
  • apiBaseUrlInterceptor prepends that URL to all /api/* requests, so the preview SPA can reach the production backend from a different origin
  • CORS is configured in Program.cs to allow any *.azurestaticapps.net origin
  • preview.yml GitHub Actions workflow: builds with --configuration preview, copies staticwebapp.config.json for SPA routing, deploys to Azure SWA; closes the staging environment when the PR is closed
  • staticwebapp.config.json configures SPA fallback routing so Angular's router works correctly on direct URL access

Azure setup completed

  • SWA resource angular-cli-netcore-ngrx-starter created (free tier, East US 2)
  • AZURE_STATIC_WEB_APPS_API_TOKEN secret added to the repository

Notes

  • Preview environments hit the production API — acceptable for UI-focused PRs
  • No .NET build in the preview pipeline → much faster CI
  • The standard ci.yml workflow still runs in parallel for lint/test/build checks

@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://green-water-08792290f-65.eastus2.2.azurestaticapps.net

Closes #64

- Add apiBaseUrlInterceptor: prepends apiBaseUrl to /api/* requests,
  allowing the Angular app to call the production backend from a
  different origin in preview builds
- Add environment files: environment.ts (empty = same-origin, used in
  dev and prod) and environment.preview.ts (production App Service URL)
- Add preview build configuration in project.json with fileReplacements
  to swap in environment.preview.ts
- Add staticwebapp.config.json for SPA fallback routing in Azure SWA
- Add CORS policy in Program.cs allowing *.azurestaticapps.net origins
- Add preview.yml workflow: builds Angular with the preview config,
  deploys to Azure SWA on PR open/sync, closes staging env on PR close

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@chrisjwalk chrisjwalk force-pushed the feat/swa-preview-64 branch from d00d543 to 8e22b81 Compare March 15, 2026 17:58
Captures static_web_app_url output from the deploy step and posts it
as a comment on the PR. Updates the existing comment on re-deploys
rather than adding a new one each time.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://green-water-08792290f-65.eastus2.2.azurestaticapps.net

@github-actions
Copy link
Copy Markdown

Azure/static-web-apps-deploy already posts a PR comment when repo_token
is provided. Remove the redundant actions/github-script step.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Owner

@chrisjwalk chrisjwalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE!

@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://green-water-08792290f-65.eastus2.2.azurestaticapps.net

@chrisjwalk-bot chrisjwalk-bot merged commit 68657b9 into main Mar 15, 2026
3 checks passed
@chrisjwalk-bot chrisjwalk-bot deleted the feat/swa-preview-64 branch March 15, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: PR preview deployments using Azure Static Web Apps

2 participants