Skip to content

Migrate remaining infra PowerShell deploy scripts to bash - #300

Open
patoperpetua wants to merge 5 commits into
mainfrom
chore/296-migrate-infra-ps1-to-bash
Open

Migrate remaining infra PowerShell deploy scripts to bash#300
patoperpetua wants to merge 5 commits into
mainfrom
chore/296-migrate-infra-ps1-to-bash

Conversation

@patoperpetua

@patoperpetua patoperpetua commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Closes #296

Preview scenarios: not-applicable — tooling/infra migration only

Summary

Base

Targets main. Includes #298 commits until #298 merges (then GitHub will show only the bash-port delta). Prefer merging #298 first, then this PR.

Test plan

  • bash -n on all three new scripts
  • --help smoke for each script
  • Human (with az login): ./infra/deploy.sh --what-if, ./infra/deploy-aca-preview.sh --what-if, ./infra/migrate-db.sh --what-if
  • Confirm no remaining infra/*.ps1 deploy paths in docs touched by this PR

Feedback focus

  • Flag any PowerShell-only Azure CLI quirks that the bash ports miss.
  • Confirm dropping refresh-database-url.sh is correct given Neon KV URLs.

Related

patoperpetua and others added 2 commits September 1, 2026 12:00
Stop provisioning Azure SQL in main.bicep/deploy.ps1. Document Neon
database-url / database-url-unpooled Key Vault secrets, update migrate-db
for PostgreSQL directUrl, and drop the SQL-only refresh-database-url script.

Co-authored-by: Cursor <cursoragent@cursor.com>
Port deploy, deploy-aca-preview, and migrate-db to bash (Neon-aware),
delete the .ps1 counterparts, and point docs/workflows at the .sh paths.
refresh-database-url.ps1 stays removed (obsolete after Azure SQL IaC exit).

Co-authored-by: Cursor <cursoragent@cursor.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @patoperpetua, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 6 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 2f365b94-9c06-497b-aa9e-5e553b21c4fb

📥 Commits

Reviewing files that changed from the base of the PR and between 2a201ee and 75f8883.

📒 Files selected for processing (18)
  • .env.example
  • .github/workflows/preview-api.yml
  • SETUP.md
  • docs/db-practices.md
  • docs/pr-pipelines.md
  • docs/telemetry.md
  • infra/README.md
  • infra/container-apps-preview.bicep
  • infra/deploy-aca-preview.ps1
  • infra/deploy-aca-preview.sh
  • infra/deploy-openfga.sh
  • infra/deploy.ps1
  • infra/deploy.sh
  • infra/main.bicep
  • infra/main.json
  • infra/migrate-db.ps1
  • infra/migrate-db.sh
  • infra/refresh-database-url.ps1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Human Review Brief — Migrate remaining infra PowerShell deploy scripts to bash

Summary

Test evidence

  • Local commands: see PR test plan
  • conflict-on-pr: SUCCESS (log)

Preview URLs

Open review threads

  • None

Infra blockers

  • None

Visual review

  • Chromatic visual-accept is human-only. Agents must not treat visual-change builds as required CI.

Next action

READY FOR HUMAN

@sourcery-ai

sourcery-ai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR completes the infrastructure tooling migration from PowerShell to strict-mode Bash by adding three secure, option-driven deployment/migration scripts, removing their PowerShell counterparts, and updating all related documentation, workflow guidance, Bicep comments, and cross-script instructions for the Neon/Azure deployment model.

Sequence diagram for Neon database migration

sequenceDiagram
    actor Operator
    participant Script as migrate-db.sh
    participant AzureCLI as Azure CLI
    participant KV as Key Vault
    participant Prisma as Prisma
    participant Neon as Neon PostgreSQL

    Operator->>Script: migrate-db.sh
    Script->>AzureCLI: az account set
    Script->>KV: secret show database-url
    KV-->>Script: pooled URL
    Script->>KV: secret show database-url-unpooled
    KV-->>Script: direct URL or fallback
    Script->>Script: Write packages/db/.env
    Script->>Prisma: pnpm exec prisma migrate deploy
    Prisma->>Neon: Apply forward-only migrations
    Prisma-->>Script: Migration status
Loading

File-Level Changes

Change Details Files
Replace the remaining PowerShell infrastructure deployment entry points with strict-mode Bash scripts and preserve their Azure provisioning, secret handling, and database migration workflows.
  • Add Bash implementations for core Azure/Bicep deployment, ACA preview provisioning, and Prisma/Neon migration operations.
  • Support --help, --what-if, deployment-specific options, and status-only database checks.
  • Use secure temporary files and restrictive permissions for generated .env files, while avoiding secret logging.
  • Retain Neon PostgreSQL and Key Vault/App Configuration integration, including ACR credential and connection-string synchronization.
infra/deploy.sh
infra/deploy-aca-preview.sh
infra/migrate-db.sh
infra/deploy.ps1
infra/deploy-aca-preview.ps1
infra/migrate-db.ps1
Update infrastructure documentation, operational guidance, workflow comments, and Bicep headers to use the new Bash commands and Neon-based terminology.
  • Replace PowerShell invocation examples and prerequisite text with Bash equivalents.
  • Document --alert-email, --what-if, and --status-only command forms.
  • Update ACA preview, database migration, telemetry, setup, and OIDC guidance to reference the Bash scripts.
  • Remove obsolete references to the deleted database URL refresh flow and clarify Neon CLI/database URL prerequisites.
infra/README.md
SETUP.md
docs/db-practices.md
docs/pr-pipelines.md
docs/telemetry.md
.github/workflows/preview-api.yml
infra/container-apps-preview.bicep
infra/main.bicep
Update cross-script dependency and failure guidance so OpenFGA deployment points to the new Bash provisioning sequence.
  • Replace missing-resource remediation messages with deploy.sh and deploy-aca-preview.sh commands.
infra/deploy-openfga.sh

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

API preview (Container Apps Consumption)

Preview URL: https://ssd-pocpk-aca-pr-300-ae.victoriouscliff-509c369b.australiaeast.azurecontainerapps.io

  • App: ssd-pocpk-aca-pr-300-ae (scale-to-zero)
  • Image: ssdpocpkacrdevae.azurecr.io/pocpk-api:pr-300
  • Path B: ephemeral ACA per PR — not F1 overwrite, not S1 slots
  • Cleanup runs when this PR is closed

Database

  • Mode: SQLite (ephemeral) — an isolated, disposable database baked into this image; never the shared Azure SQL database.
  • Active scenarios: demo
  • Reset behaviour: every container start (including a redeploy after pushing new commits) copies the immutable seeded template back over the writable database — any changes made while testing are discarded, not carried forward.
  • Verify without manual setup: GET /health/db returns 200 only once every active scenario's fixtures were found in this container's copy of the database (see docker-entrypoint.sh).

See docs/preview-scenarios.md for each scenario's test instructions and known SQLite vs SQL Server limitations.

Web SWA PR previews remain via preview-web.yml; production API/web via deploy-api.yml / deploy-web.yml on main.

patoperpetua and others added 3 commits September 4, 2026 11:20
Validate DATABASE_URL* schemes before Key Vault upsert, and fail closed
when database-url-unpooled is missing so Prisma never migrates via PgBouncer.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Keep PowerShell scripts deleted. Require database-url-unpooled in
migrate-db.sh and reject non-Postgres DATABASE_URL* in deploy.sh.

Co-authored-by: Cursor <cursoragent@cursor.com>
@patoperpetua
patoperpetua changed the base branch from feat/291-remove-azure-sql-neon to main September 4, 2026 01:24
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.

Migrate remaining infra PowerShell deploy scripts to bash

1 participant