Skip to content
Draft
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
11 changes: 11 additions & 0 deletions .github/workflows/hub-azure-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,17 @@ jobs:
--state-resource-group "$AZURE_STATE_RESOURCE_GROUP" \
--state-account "$AZURE_STATE_STORAGE_ACCOUNT" \
--state-container "$AZURE_STATE_CONTAINER"
- name: Keep public sharing
env:
TF_DATA_DIR: ${{ runner.temp }}/public-share-terraform
HUB_IMAGE: ${{ steps.image.outputs.reference }}
run: |
node infrastructure/azure/deploy-hub/public-share/index.ts \
--variables "$RUNNER_TEMP/installation.tfvars.json" \
--image "$HUB_IMAGE" \
--state-resource-group "$AZURE_STATE_RESOURCE_GROUP" \
--state-account "$AZURE_STATE_STORAGE_ACCOUNT" \
--state-container "$AZURE_STATE_CONTAINER"
- name: Run the serialized maintenance-window release
env:
TF_DATA_DIR: ${{ runner.temp }}/terraform
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/hub-infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
version: ["1.13.4", "1.17.1"]
module: [".", "foundation", "provision", "private-preview"]
module: [".", "foundation", "provision", "private-preview", "public-share"]
command: ["fmt -check -recursive", "validate", "test"]
defaults:
run:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
- run: node --test deploy-hub/index.test.ts deploy-hub/private-preview/index.test.ts stop-hub/index.test.ts ../installer/command/describe/index.test.ts
- run: node --test deploy-hub/index.test.ts deploy-hub/private-preview/index.test.ts deploy-hub/public-share/index.test.ts stop-hub/index.test.ts ../installer/command/describe/index.test.ts

installer:
name: Installer ${{ matrix.command }}
Expand Down
4 changes: 4 additions & 0 deletions hub/docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ Versioned references make rotation explicit. An unversioned runtime/setup URL is

The Azure entrypoint also supports the scoped [GitHub author repair and webhook checks](github-actions-builds.md#commit-authors). These maintenance targets load the same runtime secret references into their own process before importing the command.

### Public share reader

The same image runs the read-only [public share reader](public-share-reader.md) with `node dist/server/scripts/start-public-share-reader/index.js`. It is a separate deployment with its own settings and identity; never give it Hub's settings, which stop it at startup. The Azure installation runs it as an optional component, off by default, in its own Container Apps environment with a separate export storage account. Turning [public sharing](../../infrastructure/README.md#public-sharing) on with setup Update also sets Hub's `HUB_PUBLIC_SHARE_ENABLED`, `HUB_PUBLIC_SHARE_ORIGIN`, `HUB_PUBLIC_SHARE_STORAGE_ACCOUNT` and `HUB_PUBLIC_SHARE_STORAGE_CONTAINER`, plus `HUB_PUBLIC_SHARE_ALLOW_SHARED_SITE=true` only for a non-production installation that accepts the shared-site override. Hub uses its existing managed identity for the export container. Sharing also needs complete GitHub sign-in, which setup Update checks before turning it on. Setup Update owns these settings; do not set them by hand or through the release workflow's runtime JSON.

## Setup before release

Run `npm run setup` from `hub/`, or invoke `node dist/server/scripts/setup/index.js` inside the image. Normal API and worker startup never runs setup.
Expand Down
54 changes: 54 additions & 0 deletions infrastructure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,50 @@ The wizard sets these Hub settings itself and replaces manual values: `HUB_PRIVA

**Staging pilot.** Staging's hand-created pilot inline app, `rep-hub-cai-stage-1-inline`, and its identity and grants are not in Terraform state. The wizard neither imports nor manages them. Retire them manually after the shared reader is verified on Staging. Its Terraform-managed reader, `rep-hub-cai-stage-1-preview`, is kept and upgraded in place. If the reader identity or Hub's identity still has access to `private-preview-artifacts` that the wizard did not create, Update stops before any change and names each grant; remove or review it, then rerun.

### Public sharing

Public sharing lets signed-in Hub users give anyone a link to one Build. Hub copies the Build into a separate export storage, and a separate read-only reader serves the copy. [ADR 0003](../docs/adr/0003-public-sharing-export-reader.md) is the design and the [public share reader guide](../hub/docs/public-share-reader.md) describes the reader. Update asks for this setting after the private prototype service. Create keeps it off, because the choice depends on Hub's hostname, which exists only after the first release.

- **Off** (default). Hub has no public sharing settings and the reader has no ingress. A configuration that never turned sharing on creates nothing, and no Terraform runs for it, including after an attempt to turn it on stopped before creating anything. After sharing has been on, Off keeps the reader as a placeholder without ingress, removes Hub's export grant, and keeps the export storage and every copied export.
- **On.** Creates or updates the export storage, the reader and its grants, and Hub's export grant, then releases Hub with the sharing settings below. Turning sharing on needs Hub's `HUB_APPLICATION_ORIGIN` and complete GitHub sign-in from [post-setup](#post-setup-configuration), because Hub refuses to share without them; local administrator sign-in alone is not enough. The installation always configures Hub's artifact storage. Update checks the choice against Hub's saved settings before saving it or changing Azure, and asks again if it doesn't fit.
- **Remove** is the rollback. It deletes the reader app, its custom hostname, every reader grant and Hub's export grant, and turns sharing off in Hub. It keeps the export storage account, container and data, and the reader's resource group, environment and identity.

Non-default choices are saved in the installation configuration as `publicShare`, for example `{ "reader": "on" }`. Non-interactive Update applies the saved choice. Rerunning Update with the same choice changes nothing except the image that Hub and the reader run.

**Hub's hostname.** Browsers treat every generated `azurecontainerapps.io` hostname as one site, so a Hub on its generated hostname would be same-site with every shared prototype. Update therefore refuses to turn sharing on while Hub's `HUB_APPLICATION_ORIGIN` is a generated hostname; give Hub a custom domain with [post-setup](#post-setup-configuration) first. A non-production installation, such as Staging, may accept the trade-off instead: Update offers this only while Hub uses a generated hostname, shows the warning, and requires you to select that the installation is not production. It then saves `"allowSharedSite": true` and sets `HUB_PUBLIC_SHARE_ALLOW_SHARED_SITE=true` on Hub. Update refuses the override when Hub has a custom domain, so a Production Hub on its custom domain never receives it. Post-setup refuses to change Hub's origin while sharing is on; turn it off with Update first.

**Link hostname.** Links use the reader's generated hostname, `<name>-share.<environment domain>`, in every installation. You can enter an optional custom domain for links. It must be outside `azurecontainerapps.io` and under a different registered domain from Hub's, such as `share.example.net` beside `replica.example.com`. The first Update with a custom domain prints its CNAME and TXT records; add them and run Update again. The wizard checks that both resolve, adds the hostname to the reader, and asks Azure for a managed certificate. Until the certificate is bound, new links keep using the generated hostname. The reader accepts both origins, so links on the generated hostname keep working after a custom domain is added. Changing or removing the custom domain while sharing is on is not supported; turn sharing off first. Links on the generated hostname stop working if the reader app or its environment is recreated.

**What is created.** In the `<name>-share` resource group:

- The export storage account `<name without hyphens>pub` and its private `public-share-exports` container. Shared keys and anonymous access are off. Blobs are not versioned or soft-deleted, because Hub deletes copied files within 24 hours of revocation or expiry; the container can be restored for 7 days.
- The reader's Container Apps environment, without a subnet, so the reader has no network path to Hub's database, Key Vault or storage. It sends logs to Hub's existing Log Analytics workspace and pulls from the installation registry.
- The reader app `<name>-share`. It runs Hub's immutable image digest with `node dist/server/scripts/start-public-share-reader/index.js`, as the non-root user, behind HTTPS-only ingress, with one replica and TCP startup, readiness and liveness probes.
- The reader's user-assigned identity `<name>-share`.

**What is granted.** The reader identity gets `AcrPull` on the installation registry and one `Storage Blob Data Reader` assignment on `public-share-exports` with an ABAC 2.0 condition that denies blob listing. It cannot list, write or delete exports, and gets nothing else. Hub's identity, which runs the API and workers, gets `Storage Blob Data Contributor` on `public-share-exports` only, while sharing is on. Before and after every change, the wizard checks both identities' effective grants, including grants through groups and at parent scopes, and stops on any grant it didn't create.

**Settings.** The wizard sets these Hub settings itself and replaces manual values; a Key Vault reference for any of them blocks Update:

| Setting | Value |
| --- | --- |
| `HUB_PUBLIC_SHARE_ENABLED` | `true` while sharing is on; unset otherwise |
| `HUB_PUBLIC_SHARE_ORIGIN` | The custom origin once its certificate is bound, otherwise the generated origin |
| `HUB_PUBLIC_SHARE_STORAGE_ACCOUNT`, `HUB_PUBLIC_SHARE_STORAGE_CONTAINER` | The export account and `public-share-exports` |
| `HUB_PUBLIC_SHARE_ALLOW_SHARED_SITE` | `true` only with the non-production override; unset otherwise |

The reader gets only its own settings: `PUBLIC_SHARE_GENERATED_ORIGIN`, `PUBLIC_SHARE_CUSTOM_ORIGIN` once a custom domain is bound, `PUBLIC_SHARE_TRUSTED_PROXY_HOPS=1`, `PUBLIC_SHARE_STORAGE_PROVIDER=azure`, the export account and container, and its own `AZURE_CLIENT_ID`. It refuses to start beside any Hub setting.

**Order.** Before the Hub release, the wizard applies everything Hub may still use: a reader that is turning off stays on, with its custom hostname and Hub's export grant. On first enablement it waits for the reader's revision to become ready; if it doesn't, Hub's sharing stays off and the next Update rechecks. After the release, it disables or removes what the new Hub no longer uses, only if the serving Hub still has the settings this release gave it. Every plan is checked: only public sharing resources may change, nothing may be imported or moved, only the reader app may be updated, and the storage account, container, environment, identity and resource group are never updated, replaced or deleted. They also have Terraform's `prevent_destroy`. Saved state uses the same [fail-closed lineage checks](#private-prototype-service) as the private prototype service, with the `public-share.tfstate` key and the `<name>-share` group.

**Turn sharing on in Staging.** After this change and the Hub change that reads these settings are released to Staging:

1. Confirm Staging's saved inputs have complete GitHub sign-in and `HUB_APPLICATION_ORIGIN`. Run `npm run setup:server`, choose **Update**, and select Staging's configuration.
2. Choose **Public sharing: On** and leave the custom domain blank. Staging's Hub uses its generated hostname, so Update shows the shared-site warning; select the non-production option.
3. Review and approve the deployment. Update creates the `<name>-share` resources, waits for the reader, releases Hub with the sharing settings, and prints the link origin.

To roll back, run Update and choose **Remove** (or **Off** to keep a disabled reader). Exports stay in `public-share-exports`.

### Local checks

```sh
Expand Down Expand Up @@ -444,6 +488,16 @@ Before the release, the workflow keeps the [private prototype service](#private-

Missing saved state while Hub has private preview settings, or state from the earlier preparation step, also stops the workflow. Use setup Update for every other change. The deployment identity needs Container Apps write access on the reader's resource group and Blob data access to the `private-preview.tfstate` key in the state container.

### Public sharing releases

The workflow keeps [public sharing](#public-sharing) the same way, in its own step after the private prototype service. It never turns sharing on or off:

- It copies Hub's current `HUB_PUBLIC_SHARE_*` settings from the running Hub into the release inputs. Do not put those names in `AZURE_RUNTIME_ENVIRONMENT_JSON` or `AZURE_RUNTIME_SECRET_REFERENCES_JSON`; the workflow stops if they are there.
- If Hub shares, it checks that the reader is on, Hub's export grant is in saved state, Hub's link origin is one of the reader's origins, Hub and the reader use the same export account and container, and the shared-site override is set exactly when Hub's origin is a generated hostname.
- It moves the reader to the release image. The public-share plan may change only that image. The apply holds the release lock and the same saved-state checks as Update.

Missing `public-share.tfstate` while Hub has sharing settings also stops the workflow. The deployment identity needs Container Apps write access and resource read access on the `<name>-share` resource group, and Blob data access to the `public-share.tfstate` key in the state container.

### Deploy, recover, and verify

Select **Actions**, **Deploy Hub to Azure development**, **Run workflow**, then approve the `hub-azure-development` Environment deployment. The release command retains its infinite lease when setup, rollout, digest verification, readiness, health, or provider-configuration checks fail. Review the failed setup execution, active revision and image digest, and Terraform state before following the existing [interrupted-installation recovery](#interrupted-installation) procedure. Do not cancel a running deployment or break its lease.
Expand Down
8 changes: 6 additions & 2 deletions infrastructure/azure/deploy-hub/private-preview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ export async function keepPrivatePreview({
}

// Returns whether the plan moves the reader to the image, and rejects any other change.
export function onlyImageChange(plan: { resource_changes?: Change[] }, image: string): boolean {
export function onlyImageChange(
plan: { resource_changes?: Change[] },
image: string,
fail: (reason: string) => never = block,
): boolean {
let changed = false
for (const { address, change } of plan.resource_changes ?? []) {
const actions = Array.isArray(change?.actions) ? change.actions.join("/") : ""
Expand All @@ -239,7 +243,7 @@ export function onlyImageChange(plan: { resource_changes?: Change[] }, image: st
after?.template?.[0]?.container?.[0]?.image !== image ||
keys.some((name) => !sameJson((withImage as Record<string, unknown>)[name], (after as Record<string, unknown>)[name]))
)
block(`the release would ${actions} ${String(address)} beyond moving the reader to the new image.`)
fail(`the release would ${actions} ${String(address)} beyond moving the reader to the new image.`)
changed = true
}
return changed
Expand Down
Loading
Loading