ADR: The deploy pipeline
Status: accepted, 2026-09-02, the morning it shipped. The first automated
deploy rolled 1.0.0.12 onto the live site with no hands on the runner.
In plain words
A change reaches the live site with no person involved. When the tests pass on the main branch, a second automated job (GitHub Actions) builds and ships the new image, then checks that the live site reports the new version. It signs in to Azure with a short-lived token (OIDC), so no password or key is stored anywhere.
What that is worth: a developer merges and the deploy follows on its own with nothing to rotate or leak, and the organization gets releases that need neither a laptop nor a stored credential.
Context
Until this morning every ship was a scripted manual pipeline: run the three
suites, build the image on the laptop, push it to the registry, export the
running container group, strip the lines Azure refuses, patch the tag,
recreate the group, poll, verify. Logged end to end and gated on green
tests, but a person still started it and a laptop still had to be on. The
version number (1.0.0.N) was typed by hand for each ship.
The goal, in one sentence: a merge to main reaches the live site with no
human step and no credential stored anywhere.
Decision
A second GitHub Actions workflow, Deploy, separate from CI on purpose.
- It fires when CI finishes green on main, through GitHub's
workflow_run trigger, and checks out the exact commit CI tested rather
than whatever main has moved to since. A red CI run still fires the
event; a job-level condition drops it before anything builds.
- It builds the image with the two footer build arguments, APP_VERSION
and APP_COMMIT, so the page keeps reporting exactly what is running
(ADR: Version in the footer, under Best Practices).
- It pushes to the registry and rolls the container group from a
template checked into infra/, aci-theyard.yaml, the same file every
deploy uses. The template is the v11 export with the three line
families Azure rejects removed and the image line replaced by a
placeholder the workflow fills in. It holds no secrets: the registry
pull rides the container group's user-assigned identity.
- Authentication is OIDC federated credentials. The workflow asks
GitHub for a short-lived token for this repository and this branch, and
Azure trusts that token for one app registration whose federated
credential subject is pinned to
repo:SteveStout@317307255/TheYard@1352398185:ref:refs/heads/main.
GitHub holds three identifiers as repository variables (client, tenant,
subscription), which are not secrets. No password, key, or secret exists
anywhere in the pipeline, so there is nothing to rotate and nothing to
leak.
- Roles are scoped to least privilege: AcrPush on the one registry,
Azure Container Instances Contributor Role on the one resource group, and
Managed Identity Operator on the one identity the container group assigns
at create time. The scoped set worked on the first deploy; the wider
Contributor fallback the plan allowed for was never needed.
- Displayed versions are read from the changelog's top line. They were
1.0.0.(11 + deploy run number) until 1.0.0.41, the offset being what the
footer showed the morning this workflow was written. A red CI run consumes a
run number without shipping anything, so that formula could name a version
nothing ever displayed, and once did. ADR: The version comes from the
changelog holds the replacement and the incident.
- Deploys are serialized. A concurrency group makes two quick merges
wait their turn instead of fighting over one container group.
- The workflow verifies what it shipped the way the runner scripts did:
it waits for the origin to answer with the new version string, then
checks the domain for the same version and commit and a live inventory
endpoint. A green Deploy run means what a green runner log meant.
In the code
The workflow is .github/workflows/deploy.yml
and the template it renders is infra/aci-theyard.yaml.
The samples below are read from this build's copy of the workflow each time
the page is served (ADR: Live code samples). The trigger and the gate:
on:
push:
branches: [main]
paths-ignore:
- 'functions/**'
- 'infra/jobhunt.bicep'
- '.github/workflows/nightly.yml'
workflow_call:
inputs:
sha:
description: The commit the gate promoted onto main
required: true
type: string
secrets:
YARD_AUTH_SIGNING_KEY:
required: true
ADMIN_KEY:
required: true
NETLIFY_TOKEN:
required: true
LINKEDIN_CLIENT_ID:
required: false
LINKEDIN_CLIENT_SECRET:
required: false
permissions:
id-token: write
contents: read
packages: write
concurrency:
group: deploy-production
cancel-in-progress: true
jobs:
deploy:
Live from .github/workflows/deploy.yml, region deploy-trigger, read from this build at 99df7a8.
The checkout pinned to the commit CI tested, the version arithmetic, and
the changelog check that joined the step later (ADR: The changelog):
- uses: actions/checkout@v7
with:
ref: ${{ inputs.sha || github.sha }}
- name: The commit is main's head
env:
SHA: ${{ inputs.sha || github.sha }}
run: |
git fetch -q --depth=1 origin +refs/heads/main:refs/remotes/origin/main
[ "$(git rev-parse origin/main)" = "$SHA" ] || { echo "::error::$SHA is no longer main's head"; exit 1; }
- name: Compute version
env:
HEAD_SHA: ${{ inputs.sha || github.sha }}
run: |
# The changelog's top line is the version (ADR-031). Not a run
# counter: a counter ticks on runs that are gated off and never ship,
# which is how 1.0.0.39 became a number the changelog named and
# nothing ever displayed.
# Four numbers since 1.0.1.0, compared as a version (sort -V), not as
# the one counter it was while every version began 1.0.0.
VERSIONS=$(sed -n 's/^- \*\*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)\*\*.*/\1/p' docs/CHANGELOG.md)
N=$(echo "$VERSIONS" | sed -n 1p)
PREV=$(echo "$VERSIONS" | sed -n 2p)
# #region changelog-check
# Both of these used to be a warning nobody reads. They stop the
# deploy now, because the file they check is where the version comes
# from: shipping past either one means shipping a number with no
# sentence attached to it (ADR-031).
if [ -z "$N" ]; then
echo "::error file=docs/CHANGELOG.md::No version line at the top of the changelog, so there is no version to ship"
exit 1
fi
if [ -n "$PREV" ] && { [ "$N" = "$PREV" ] || [ "$(printf '%s\n%s\n' "$PREV" "$N" | sort -V | tail -1)" != "$N" ]; }; then
echo "::error file=docs/CHANGELOG.md::The top line is $N and $PREV is already below it, so this ship has no changelog line of its own"
exit 1
fi
# #endregion changelog-check
{
echo "N=$N"
echo "APP_VERSION=$N"
echo "APP_COMMIT=${HEAD_SHA:0:7}"
echo "GHCR_IMAGE=ghcr.io/stevestout/theyard:v$N"
} >> "$GITHUB_ENV"
echo "Deploying $N from ${HEAD_SHA:0:7} as ghcr.io/stevestout/theyard:v$N"
Live from .github/workflows/deploy.yml, region compute-version, read from this build at 99df7a8.
The roll, which is the whole deploy step:
- name: Roll the site
env:
YARD_AUTH_SIGNING_KEY: ${{ secrets.YARD_AUTH_SIGNING_KEY }}
ADMIN_KEY: ${{ secrets.ADMIN_KEY }}
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
LINKEDIN_CLIENT_ID: ${{ secrets.LINKEDIN_CLIENT_ID }}
LINKEDIN_CLIENT_SECRET: ${{ secrets.LINKEDIN_CLIENT_SECRET }}
run: |
# Resource Manager sometimes answers a write with a gateway error (BadGatewayConnection on
# 1.0.3.182's roll of the SQL site); each write is tried three times, a minute apart, before
# the roll is red, and the same write twice is the same setting (ADR: The deploy pipeline).
arm() { for try in 1 2 3; do "$@" && return 0; echo "::warning::Resource Manager refused $1 $2 $3 $4, try $try of 3"; [ "$try" = 3 ] || sleep 60; done; return 1; }
# The Application Insights connection string is an ingestion key, so it
# lives only in Azure: read it here with the credential this job already
# holds and mask it in the log. az resource show is core CLI; az monitor
# app-insights would pull an extension at run time, which is a second
# thing that can fail a deploy. Telemetry is an addition, not a
# dependency: if the read fails, the site keeps the value it has and
# still ships, because a deploy pipeline held hostage to its own
# observability is worse than a quiet hour of no traces.
CONN=$(az resource show -g "$RG" -n "$AI_NAME" \
--resource-type "Microsoft.Insights/components" \
--query "properties.ConnectionString" -o tsv 2>/dev/null || true)
if [ -n "$CONN" ]; then
echo "::add-mask::$CONN"
fi
# The database. The value names a server, a database and an
# authentication mode; the credential is the site's managed identity,
# which never leaves Azure. The name is composed rather than read back
# from Azure: the first version of this asked `az sql server show`,
# which this job's identity is not allowed to do, the call failed
# silently, and 1.0.0.49 shipped on SQLite and said so. An Azure SQL
# logical server's address is its name plus the service suffix. No
# Connect Timeout, on purpose: YardConnection widens a timeout nobody
# gave to sixty seconds, and a value given here wins over that
# (ADR: The SQL Server backend).
YARD_SQL=""
if [ -n "$SQL_SERVER" ]; then
YARD_SQL="Server=tcp:${SQL_SERVER}.database.windows.net,1433;Initial Catalog=${SQL_DB};Encrypt=True;TrustServerCertificate=False;Authentication=Active Directory Managed Identity;User Id=${MI_CLIENT_ID};"
fi
# #region secrets
# The session signing key and the operator's key, from the repository
# secrets of the same names, handed to the step through env and written
# to a file by python, so neither is ever part of a command line and
# neither appears in a log: GitHub masks them, and the settings call
# prints nothing. A value this job does not hold is left out, and the
# site keeps what it has: the template's placeholder on a new site,
# which the app reads as "no key", or the last roll's value
# (ADR: Three readers with no memory of the project; ADR: Site
# activity, and the line an address does not cross).
CONN="$CONN" YARD_SQL="$YARD_SQL" python3 - "$RUNNER_TEMP/settings.json" <<'PY'
import json, os, sys
wanted = {
"APPLICATIONINSIGHTS_CONNECTION_STRING": os.environ.get("CONN", ""),
"ConnectionStrings__YardSql": os.environ.get("YARD_SQL", ""),
"Auth__SigningKey": os.environ.get("YARD_AUTH_SIGNING_KEY", ""),
"Admin__Key": os.environ.get("ADMIN_KEY", ""),
}
# The Netlify token is optional: the edge card says in a sentence when
# it is missing, so an unset secret is a plain line here, not a warning
# (ADR: One frame for every resource).
# The LinkedIn app's two values are optional too: until they exist the LinkedIn
# posting card says "Not set up yet" (ADR: LinkedIn posting through the
# self-serve API).
optional = {
"Netlify__Token": os.environ.get("NETLIFY_TOKEN", ""),
"LinkedIn__ClientId": os.environ.get("LINKEDIN_CLIENT_ID", ""),
"LinkedIn__ClientSecret": os.environ.get("LINKEDIN_CLIENT_SECRET", ""),
}
held = [{"name": name, "value": value, "slotSetting": False} for name, value in {**wanted, **optional}.items() if value]
for name, value in wanted.items():
if not value:
print(f"::warning::{name} is not held by this job; the site keeps the value it has")
for name, value in optional.items():
if not value:
print(f"{name} is not set; the card that reads it says so")
json.dump(held, open(sys.argv[1], "w", encoding="utf-8"))
print(f"{len(held)} of {len(wanted) + len(optional)} values go to the site (values masked)")
PY
# #endregion secrets
if [ "$(cat "$RUNNER_TEMP/settings.json")" != "[]" ]; then
arm az webapp config appsettings set -g "$RG" -n "$APP" --settings "@$RUNNER_TEMP/settings.json" -o none
fi
rm -f "$RUNNER_TEMP/settings.json"
# The image is the only thing that changes between rolls. App Service
# starts the new container beside the old one and moves traffic when
# the new one answers, so the site serves through its own roll.
# It is pulled from GitHub's registry, which serves a public package to
# anyone, so the identity's registry pull is turned off in the same write
# and no credential is stored (ADR-009, the addendum on rolling from it).
arm az webapp config set -g "$RG" -n "$APP" --linux-fx-version "DOCKER|$GHCR_IMAGE" --generic-configurations '{"acrUseManagedIdentityCreds": false}' -o none
az webapp show -g "$RG" -n "$APP" --query "{state:state, image:siteConfig.linuxFxVersion, host:defaultHostName}" -o json
Live from .github/workflows/deploy.yml, region roll, read from this build at 99df7a8.
The footer build arguments the image is stamped with live in the
Dockerfile (ADR: Version in the footer).
The first run failed, and the failure is worth keeping
Deploy run 1 stopped at the Azure sign-in with AADSTS700213: no federated
identity record matched the presented subject. The credential had been
created with the form every guide shows, repo:SteveStout/TheYard:ref:refs/heads/main.
The token GitHub actually presents carries the owner id and the repository
id inside the subject, repo:SteveStout@317307255/TheYard@1352398185:ref:refs/heads/main,
so a renamed or re-created repository can never inherit the trust. Azure
matches the subject character for character. The credential was updated to
the measured form and the run re-ran green. The lesson: read the subject
off the failing assertion, never off a guide.
What this replaced
The scripted manual pipeline retires to fallback duty and stays documented,
because it is also the rollback: az container create against the kept v11
export restores the last manual build in one command, and the same command
against any later export restores that build. Nothing was deleted.
Consequences
- The laptop no longer has to be on for a ship, and no version number is
typed by hand again.
- The roll still has the same short restart window the manual pipeline
had, roughly a minute while the group recreates. Accepted for this demo;
deployment slots on App Service are the production answer, already
covered by the undeployed Bicep design under Hosting.
- GitHub's hosted runner builds the image now, so a ship costs nothing on
the laptop and the Docker Desktop dependency is gone from the path.
- The manual scripts, the export-and-strip step included, are now
documentation of how it used to work rather than the way it works.
Addendum, 2026-09-20: a roll is two calls on a web app
Superseded in part on 2026-09-20, as 1.0.0.156. The roll above rendered infra/aci-theyard.yaml
and ran az container create. The sites are web apps on an App Service plan now
(ADR: One plan, two sites), and a web app keeps its settings on itself, so the roll is two calls:
the four values the template does not hold (the telemetry connection string, the database
connection string, the session signing key and the operator's key), written to a file by python and
sent with -o none so nothing is printed, and then the image. The live sample above is that step
as it is today. App Service starts the new container beside the old one and moves traffic when the
new one answers, so a site serves through its own roll, which a container group never did. The
deploy identity holds Website Contributor on the two sites and nothing else new.
Where it sits
The deploy pipeline is a deployment decision made in GitHub Actions workflows, outside every ring, so the onion and SOLID do not apply to it.
Addendum, 2026-09-09: one secret, where there were none
"No password, key, or secret exists anywhere in the pipeline" was true until
1.0.0.111. There is one now: the session signing key, a repository secret
named YARD_AUTH_SIGNING_KEY that the roll step reads through its
environment and substitutes into the container spec the way it substitutes
the connection strings, for both container groups, so a roll no longer ends
every session and a token minted by one container reads on the other. It is
the only thing the pipeline holds that is worth keeping from a reader, GitHub
masks it in every log, and the roll writes it into the group's environment as
a secure value and nowhere else. A roll with no secret keeps the placeholder,
which the application reads as no key at all, and behaves as every roll did
before (ADR: Three readers with no memory of the project). Rotating it is
changing the secret and rolling: every session ends once, which is what
every roll did until now.
More of the code
The Verify step: the origin must serve the new version, then answer
readiness, then the domain must agree (.github/workflows/deploy.yml):
- name: Verify
run: |
# Wait for the NEW build to answer at the origin. The plan is one shared
# processor, and the image has to be pulled and started on it before the
# new build answers. Every read
# here carries the self mark on its agent, so the Site activity card
# counts it as the site's own (ADR: Site activity, 24 September).
# Twenty-five minutes, read off the rolls: the new container starts 8 to 12
# minutes after the image push and is ready 2 to 3.5 minutes after that, and
# a ten-minute loop ended a roll that worked (ADR: The deploy pipeline, the
# addendum on sizing Verify). Thirty seconds a read, because an API read
# waits for the catalogue to load.
budget=1500
started=$SECONDS
body=""
until [[ "$body" == *"\"$APP_VERSION\""* ]]; do
if (( SECONDS - started >= budget )); then
echo "origin never served $APP_VERSION in ${budget}s (last answer: $body)"
exit 1
fi
sleep 5
body=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$ORIGIN/api/version" || true)
done
echo "origin serves $APP_VERSION after $((SECONDS - started))s: $body"
# The runtime the new build answers on, read from the process itself (ADR: Moving to .NET 11 in four ships, G2).
echo "origin runs on $(jq -r '.framework // "a runtime it does not name"' <<< "$body")"
# Readiness is the container's own word that its files are in place and its
# catalogue has loaded (ADR-010). The process listens before the catalogue is
# in (ADR: The ports learn to wait, the addendum on listening first). An API
# read waits for the load, so the version above usually arrives with it;
# this wait says so in the container's own words before the filters are read.
for i in $(seq 1 120); do
if curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 10 "$ORIGIN/readyz" > /dev/null 2>&1; then
echo "origin ready $(((i - 1) * 5))s after it served the version"
break
fi
if [[ "$i" -eq 120 ]]; then
echo "origin never said ready"
exit 1
fi
sleep 5
done
curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 20 "$ORIGIN/api/facets" > /dev/null
echo
# #region verify-names
# The other two names, at the origin, before any domain: the process picks the
# store, and The Shed, by the name a request arrived on, which the edge writes
# as X-Yard-Host (api/TheYard.Api/Shared/Instance/SiteHosts.cs). The Cosmos DB site's name must
# get Azure Cosmos DB with no store named, and The Shed's name must reach The
# Shed's own health check and its own page.
cosmos=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 -H "X-Yard-Host: ${COSMOS_SITE#https://}" "$ORIGIN/api/stores")
echo "the Cosmos DB site's name at the origin: $cosmos"
if [[ "$cosmos" != *'"current":"cosmos"'* ]]; then
echo "the Cosmos DB site's name did not get Azure Cosmos DB"
exit 1
fi
shed=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 -H "X-Yard-Host: ${SHED_SITE#https://}" "$ORIGIN/healthz")
shed_page=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 -H "X-Yard-Host: ${SHED_SITE#https://}" "$ORIGIN/")
echo "The Shed's name at the origin: $shed"
if [[ "$shed" != *'"healthy"'* || "$shed_page" != *"<title>The Shed</title>"* ]]; then
echo "The Shed's name did not reach The Shed's health check and page"
exit 1
fi
# #endregion verify-names
# #region verify-domains
# The domains are what a visitor sees. The edge serves the rules on the
# edge branch, which Edge branch moves only after this run succeeds
# (edge-branch.yml), because a rule that moved before its origin was
# verified would send visitors to a web app still starting. So this reads
# the domains when the edge already serves this commit's rules and they
# send the names here; when this push changed the rules, Edge branch moves
# them next and reads both names itself. The Shed's name is bound to a web
# app in Azure, not in a file, so it is read and said, never a failure here.
git fetch -q --depth=1 origin edge
if git diff --quiet FETCH_HEAD HEAD -- edge/ netlify.toml && grep -q "${ORIGIN#https://}" netlify.toml edge/_redirects; then
for domain in "$SITE" "$COSMOS_SITE"; do
site=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$domain/api/version")
echo "domain $domain: $site"
if [[ "$site" != *"\"$APP_VERSION\""* || "$site" != *"\"$APP_COMMIT\""* ]]; then
echo "$domain does not report $APP_VERSION at $APP_COMMIT"
exit 1
fi
curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$domain/api/facets" > /dev/null
done
# Both domains answer the same version; only the store says the edge sent the right name.
stores=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$COSMOS_SITE/api/stores")
if [[ "$stores" != *'"current":"cosmos"'* ]]; then
echo "$COSMOS_SITE did not get Azure Cosmos DB through the edge: $stores"
exit 1
fi
else
echo "::notice::the edge does not yet serve this commit's rules for this origin; Edge branch moves them after this run and reads both names"
fi
echo "The Shed's domain: $(curl -sS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$SHED_SITE/api/version" || true)"
# #endregion verify-domains
# Which store the container actually came up on, said out loud.
#
# A warning and not a failure, on purpose. The whole point of the
# file-backed fallback is that the site serves when the database does
# not (ADR: The relational store), so a roll that lands on SQLite is
# the design working and must not fail a deploy. What it must not be
# is silent: 1.0.0.49 shipped that way and nothing said so until
# somebody read the health endpoint by hand.
store=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$ORIGIN/api/health" || true)
case "$store" in
*"Azure SQL Database"*) echo "the site is on Azure SQL Database" ;;
*SQLite*) echo "::warning::this roll is serving from SQLite, not Azure SQL Database" ;;
*) echo "::warning::could not tell which store the container is on" ;;
esac
# Azure's own view of the container (the Admin tab's card), informational.
curl -sS --max-time 40 "$ORIGIN/api/admin/azure" || true
echo
{
echo "## Deployed $N"
echo "- commit: $APP_COMMIT"
echo "- image: $GHCR_IMAGE"
echo "- site: $SITE"
} >> "$GITHUB_STEP_SUMMARY"
Live from .github/workflows/deploy.yml, region verify, read from this build at 99df7a8.
Addendum, 2026-09-21: the deploy starts on the push, and the two sites roll together
Deploy fired when CI finished green on main, and Deploy Cosmos fired when
Deploy finished, so a version waited four and a half minutes for CI to prove
again what the gate had proven on both stores a minute earlier, and the
second site waited for the whole of the first site's roll. From 1.0.0.173
both workflows start on the push to main, which only a green gate makes (ADR:
The five-minute gate, the addendum on every check running once). Deploy
builds and pushes the image and rolls the first site; Deploy Cosmos waits for
that image's tag to be in the registry, ten minutes at most, and rolls the
second site beside it. The plan's one machine starts both new containers at
once, which costs each a little and saves the whole of one roll.
Deploy Cosmos retired on 19 October with the web app it rolled (ADR: One web app for every .NET process); its wait for the image is kept at .github/workflows/deploy-cosmos.yml at 22b3015.
The image's slow layers, npm ci, the restore and the publish, are kept in
GitHub's own build cache between runs through Buildx, so a version whose
packages did not change skips them. The cache is GitHub's and not the
registry's: the registry holds the images and nothing else, and its size is
Steve's to prune.
- name: Sign in to GitHub's registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@v4
- name: Build and push
id: build
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: |
${{ env.GHCR_IMAGE }}
build-args: |
APP_VERSION=${{ env.APP_VERSION }}
APP_COMMIT=${{ env.APP_COMMIT }}
GOOGLE_SITE_VERIFICATION=${{ vars.GOOGLE_SITE_VERIFICATION }}
cache-from: type=gha,scope=theyard
provenance: false
Live from .github/workflows/deploy.yml, region build-cache, read from this build at 99df7a8.
Addendum, 2026-09-21: the cache is written after the roll
The build step used to write every layer to the build cache (mode=max) before it returned, and the roll waited on it. On f5b81c4 the second site found the new tag in the registry 59 s before this site began to roll: that minute was the cache upload. The build now reads the cache and pushes the image, the site rolls and answers, and a last step builds the same thing again, all cache hits on the same runner, and writes the cache for the next version. A failed roll still writes it.
- name: Keep the build cache
if: always() && steps.build.outcome == 'success'
uses: docker/build-push-action@v7
with:
context: .
push: false
outputs: type=cacheonly
build-args: |
APP_VERSION=${{ env.APP_VERSION }}
APP_COMMIT=${{ env.APP_COMMIT }}
GOOGLE_SITE_VERIFICATION=${{ vars.GOOGLE_SITE_VERIFICATION }}
cache-from: type=gha,scope=theyard
cache-to: type=gha,scope=theyard,mode=max
provenance: false
Live from .github/workflows/deploy.yml, region cache-export, read from this build at 99df7a8.
Addendum, 2026-09-25: the registry keeps the newest ten images
Steve asked for the last ten deployments to be kept and older ones pruned by default. The registry held 212 tagged images and 23 untagged manifests, 14.1 GB against the Basic plan's 10 GiB, one image for every version since 31 August. The first choice was ACR's own purge as a scheduled ACR task; the subscription refuses ACR Tasks (TasksOperationsNotAllowed), so the pipeline prunes instead, in two places. After the site answers, deploy.yml reads the image list newest first, keeps the ten newest tagged images, and deletes every older one and every untagged manifest; it deletes nothing if it reads fewer than ten, or if either site runs an image outside the ten, and a refusal to delete marks the step and never fails the deploy. The deploy's identity holds AcrPush, which pushes and cannot delete, so that step deletes only once the identity is also granted AcrDelete on the registry, a grant that is Steve's to make. Until then, and after it as a second line, the ship script on the machine that makes every push runs the same rule after the roll with the owner's sign-in. The registry was pruned to ten by hand the same morning (tweaklane, queue 1425: 216 of 225 manifests deleted, 14.1 GB to 2.1 GB). DeployWorkflowTests holds the step.
Addendum, 2026-09-25: a prune that is refused is a warning
Until the deploy identity holds AcrDelete, the prune's first delete is refused, and the step went red with its orange mark on every deploy; a mark that is always there teaches a reader to skip it. From 1.0.3.26 a refused delete prints a warning naming the missing grant and ends the step green, and a site running an image outside the ten is a warning too. The step has a five-minute limit of its own, since continue-on-error does not reach the job's. Two tests hold what the step assumes: the second site's name in the prune is the one its own workflow deploys to, and every image build sets provenance: false with no second platform, so an untagged digest is a whole image and never the child of one of the ten.
Addendum, 2026-09-29: the latest push wins
Steve asked for the fastest release cycle possible, so releases can stack instead of shipping one at a time, with the pipeline always taking the latest push. Both workflows held their concurrency group with cancel-in-progress: false, so a second push to main waited in the queue behind the roll in flight and the site was rolled twice in a row to reach the same place: once to the version nobody needed any more, then to the newest.
From 1.0.3.40 both groups cancel. A newer push cancels the run in flight, queued or rolling, and that run's successor rolls the newest commit. Nothing that decides whether a version is live moved: Verify waits for the version its own run built, at the origin and at the domain, so a roll cut off between its two calls (the settings, then the image) is finished by the next run inside its own timeout. Deploy Cosmos waits for its own image tag, so its cancelled run never rolls the second site to an image the first site skipped.
concurrency:
group: deploy-production
cancel-in-progress: true
Live from .github/workflows/deploy.yml, region latest-push-wins, read from this build at 99df7a8.
Two steps must still run on a cancelled run: the build cache, so the next version's build finds its layers, and the prune that keeps the registry to ten images. always() is the condition GitHub evaluates on a cancelled run; each step also asks whether the build step finished, because a run cancelled before its image was built has no new layers to keep and no new image to count. The proof is the second push of 29 September, read off the Actions list: one run cancelled, one complete, both domains on the second version.
- name: Keep the build cache
if: always() && steps.build.outcome == 'success'
uses: docker/build-push-action@v7
with:
context: .
push: false
outputs: type=cacheonly
build-args: |
APP_VERSION=${{ env.APP_VERSION }}
APP_COMMIT=${{ env.APP_COMMIT }}
GOOGLE_SITE_VERIFICATION=${{ vars.GOOGLE_SITE_VERIFICATION }}
cache-from: type=gha,scope=theyard
cache-to: type=gha,scope=theyard,mode=max
provenance: false
Live from .github/workflows/deploy.yml, region cache-export, read from this build at 99df7a8.
Measured on the proof, 29 September. 1.0.3.40 (8c6f416) was pushed at 08:44:28 CDT and 1.0.3.41 (31a5f44) at 08:50:13, inside its roll. Both 1.0.3.40 runs ended cancelled in their Verify step, after the image was built and both sites had been handed it. On the cancelled Deploy run, Keep the build cache (15 s) and Keep the newest ten images (5 s) both ran and succeeded, so always() is what the runner honours on a cancel, with the build step's outcome as the guard. The 1.0.3.41 runs started when the cancelled run finished those two steps, about forty seconds after the push, and both sites served 1.0.3.41 at 31a5f44 by 08:59:34, nine minutes and twenty-one seconds after its push. One roll's wait was saved: before this the second push would have queued behind the whole of the first roll.
Addendum, 2026-09-29: the sample rolls on its own
Steve asked for the sample to deploy alongside TheYard, living under samples and sharing only the Bicep and the App Service plan. A developer test project was built under samples/theshed as The Shed, a solution of its own inside this repository. It deploys to a third web app on the plan the two sites share, from its own workflow, deploy-shed.yml, which runs when a push touches that folder: the version from the sample's own changelog, one image into the same registry, the site described by the sample's own Bicep in incremental mode (an existing plan and identity, one new site, nothing else in the group touched), and a verify that waits for the new build to answer at the origin.
The two site deploys ignore samples/** and the sample's workflow file, so a push that changes only the sample does not roll TheYard, and a push that changes both rolls both. The repository tests skip the folder (Repo.NotOurs): the sample holds its own copies of the house rules, in its own suite, and this suite reads TheYard. The sample's records say what it borrowed and what it left behind.
Measured on the first run, 29 September (1.0.3.46). The workflow's first version asked Azure to deploy the sample's Bicep on every run, and the deploy identity may not: it holds Website Contributor on each site and nothing at the group, which is the least it needs to roll (ADR: The code is public and the secrets are not). So the site was created once, from the same Bicep, by the owner from the runner, the identity was given the same role on the new site, and the workflow rolls it the way deploy.yml rolls: the settings, then the image. One first run failed at that step and nothing was rolled; the record and the workflow say why.
Deploy The Shed retired on 19 October, when The Shed moved into the same image and process (ADR: One web app for every .NET process); the workflow is kept at .github/workflows/deploy-shed.yml at 22b3015.
Addendum, 2026-10-08: sizing Verify from the rolls it reads
Deploy #282 for 1.0.3.98 reported failure at its Verify step while both domains rolled fine and every read after the roll passed. Verify gave the new build ten minutes from the roll to answer /api/version, with ten seconds a read. The container started 8 min 15 s after the image push, and the Azure SQL site was ready 137 s later, 24 s past the budget. The edge warm after it was skipped, so the first visitor paid for the edge misses too.
The rolls since 1.0.3.95 give the size. The new container starts 8 to 12 minutes after the image push and is ready 2 to 3.5 minutes after that (ADR-095, the roll-by-roll table). From 1.0.3.99 each deploy waits twenty-five minutes for the version, counted on the shell's clock and not in loop turns, so a slow read cannot stretch it. Each read may take thirty seconds, because an API read waits for the catalogue to load (ADR: The ports learn to wait). The wait for readiness after it keeps its ten minutes. Each job's timeout moves from thirty minutes to fifty, so the job outlasts every wait in it: the build or the wait for the image, then twenty-five minutes for the version and ten for readiness.
- name: Verify
run: |
# Wait for the NEW build to answer at the origin. The plan is one shared
# processor, and the image has to be pulled and started on it before the
# new build answers. Every read
# here carries the self mark on its agent, so the Site activity card
# counts it as the site's own (ADR: Site activity, 24 September).
# Twenty-five minutes, read off the rolls: the new container starts 8 to 12
# minutes after the image push and is ready 2 to 3.5 minutes after that, and
# a ten-minute loop ended a roll that worked (ADR: The deploy pipeline, the
# addendum on sizing Verify). Thirty seconds a read, because an API read
# waits for the catalogue to load.
budget=1500
started=$SECONDS
body=""
until [[ "$body" == *"\"$APP_VERSION\""* ]]; do
if (( SECONDS - started >= budget )); then
echo "origin never served $APP_VERSION in ${budget}s (last answer: $body)"
exit 1
fi
sleep 5
body=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$ORIGIN/api/version" || true)
done
echo "origin serves $APP_VERSION after $((SECONDS - started))s: $body"
# The runtime the new build answers on, read from the process itself (ADR: Moving to .NET 11 in four ships, G2).
echo "origin runs on $(jq -r '.framework // "a runtime it does not name"' <<< "$body")"
# Readiness is the container's own word that its files are in place and its
# catalogue has loaded (ADR-010). The process listens before the catalogue is
# in (ADR: The ports learn to wait, the addendum on listening first). An API
# read waits for the load, so the version above usually arrives with it;
# this wait says so in the container's own words before the filters are read.
for i in $(seq 1 120); do
if curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 10 "$ORIGIN/readyz" > /dev/null 2>&1; then
echo "origin ready $(((i - 1) * 5))s after it served the version"
break
fi
if [[ "$i" -eq 120 ]]; then
echo "origin never said ready"
exit 1
fi
sleep 5
done
curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 20 "$ORIGIN/api/facets" > /dev/null
echo
# #region verify-names
# The other two names, at the origin, before any domain: the process picks the
# store, and The Shed, by the name a request arrived on, which the edge writes
# as X-Yard-Host (api/TheYard.Api/Shared/Instance/SiteHosts.cs). The Cosmos DB site's name must
# get Azure Cosmos DB with no store named, and The Shed's name must reach The
# Shed's own health check and its own page.
cosmos=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 -H "X-Yard-Host: ${COSMOS_SITE#https://}" "$ORIGIN/api/stores")
echo "the Cosmos DB site's name at the origin: $cosmos"
if [[ "$cosmos" != *'"current":"cosmos"'* ]]; then
echo "the Cosmos DB site's name did not get Azure Cosmos DB"
exit 1
fi
shed=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 -H "X-Yard-Host: ${SHED_SITE#https://}" "$ORIGIN/healthz")
shed_page=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 -H "X-Yard-Host: ${SHED_SITE#https://}" "$ORIGIN/")
echo "The Shed's name at the origin: $shed"
if [[ "$shed" != *'"healthy"'* || "$shed_page" != *"<title>The Shed</title>"* ]]; then
echo "The Shed's name did not reach The Shed's health check and page"
exit 1
fi
# #endregion verify-names
# #region verify-domains
# The domains are what a visitor sees. The edge serves the rules on the
# edge branch, which Edge branch moves only after this run succeeds
# (edge-branch.yml), because a rule that moved before its origin was
# verified would send visitors to a web app still starting. So this reads
# the domains when the edge already serves this commit's rules and they
# send the names here; when this push changed the rules, Edge branch moves
# them next and reads both names itself. The Shed's name is bound to a web
# app in Azure, not in a file, so it is read and said, never a failure here.
git fetch -q --depth=1 origin edge
if git diff --quiet FETCH_HEAD HEAD -- edge/ netlify.toml && grep -q "${ORIGIN#https://}" netlify.toml edge/_redirects; then
for domain in "$SITE" "$COSMOS_SITE"; do
site=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$domain/api/version")
echo "domain $domain: $site"
if [[ "$site" != *"\"$APP_VERSION\""* || "$site" != *"\"$APP_COMMIT\""* ]]; then
echo "$domain does not report $APP_VERSION at $APP_COMMIT"
exit 1
fi
curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$domain/api/facets" > /dev/null
done
# Both domains answer the same version; only the store says the edge sent the right name.
stores=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$COSMOS_SITE/api/stores")
if [[ "$stores" != *'"current":"cosmos"'* ]]; then
echo "$COSMOS_SITE did not get Azure Cosmos DB through the edge: $stores"
exit 1
fi
else
echo "::notice::the edge does not yet serve this commit's rules for this origin; Edge branch moves them after this run and reads both names"
fi
echo "The Shed's domain: $(curl -sS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$SHED_SITE/api/version" || true)"
# #endregion verify-domains
# Which store the container actually came up on, said out loud.
#
# A warning and not a failure, on purpose. The whole point of the
# file-backed fallback is that the site serves when the database does
# not (ADR: The relational store), so a roll that lands on SQLite is
# the design working and must not fail a deploy. What it must not be
# is silent: 1.0.0.49 shipped that way and nothing said so until
# somebody read the health endpoint by hand.
store=$(curl -fsS -A "TheYard-SelfRead/1 (deploy)" --max-time 30 "$ORIGIN/api/health" || true)
case "$store" in
*"Azure SQL Database"*) echo "the site is on Azure SQL Database" ;;
*SQLite*) echo "::warning::this roll is serving from SQLite, not Azure SQL Database" ;;
*) echo "::warning::could not tell which store the container is on" ;;
esac
# Azure's own view of the container (the Admin tab's card), informational.
curl -sS --max-time 40 "$ORIGIN/api/admin/azure" || true
echo
{
echo "## Deployed $N"
echo "- commit: $APP_COMMIT"
echo "- image: $GHCR_IMAGE"
echo "- site: $SITE"
} >> "$GITHUB_STEP_SUMMARY"
Live from .github/workflows/deploy.yml, region verify, read from this build at 99df7a8.
DeployWorkflowTests holds the numbers on both workflows: a budget of 1,500 seconds named in Verify, thirty seconds on the version read, and a job timeout that covers the ten minutes before Verify plus its thirty-five. A roll that never answers still fails the run; it now fails at twenty-five minutes instead of ten.
Addendum, 2026-10-17: the runner is a version, and a wait is a fact
Two changes to how the pipeline runs, neither of them to what it builds.
GitHub says the ubuntu-latest label moves to Ubuntu 26 from 19 October 2026. A label that moves is a build that changes without a commit, which is the one thing a pipeline is for preventing, and it would have moved while nobody was watching it. Every workflow here now names ubuntu-24.04, the image they have been green on, so the migration is a change this repository makes on a day it chooses. The Shed's suite on windows-latest is left as it is: the notice is about the Ubuntu label, and that job exists to run the path rules on Windows, whichever Windows GitHub offers.
The browser suite failed twice on main on the morning of 17 October and passed on every push after it, which is the shape of a wait that is a guess rather than a test. Both places that waited on networkidle now wait on what they are actually waiting for: the landing page's shift reading waits until every figure the first paint fetches has drawn, and the Admin tab's request test waits until the tab has made a request. Playwright's own documentation discourages networkidle for this reason. Neither timeout was raised, no test was retried, and nothing was skipped.
Addendum, 2026-10-19 (1.0.3.183): a Resource Manager write is tried three times
The SQL site's roll of 1.0.3.182 failed at 11:44 UTC on its first write: Azure Resource Manager answered az webapp config appsettings set with BadGatewayConnection, "the network connectivity issue encountered for 'Microsoft.Web'", and the job went red while the Cosmos DB site, the renderer and CI on the same commit went green. A second run of the same job, unchanged, rolled the site. Each deploy workflow's writes to Resource Manager, the app settings and the image, now go through one small shell function that tries a write three times a minute apart before the roll is red, with a warning on the run page for each refusal. The writes set a value, so the same write twice is the same setting; nothing else in the roll is retried, and a red after three tries is still red.
Addendum, 2026-10-25 (1.0.4.77): both registries, on the way to GitHub's
The Azure Container Registry, Basic, costs about $5.17 a month to hold what this public repository's own registry, ghcr.io, holds for nothing. From this version Deploy and Deploy Render push every image to ghcr.io/stevestout/theyard and ghcr.io/stevestout/theyard-render as well as to the Azure registry, signed in with the workflow's own GITHUB_TOKEN and packages: write, and nothing else is granted. The roll still pulls from the Azure registry, so nothing a visitor sees changes.
The next step pulls from ghcr.io with no credential at all, which App Service can do only for a public package. A package GitHub makes from a workflow starts private, and its visibility is a setting on the package, not on the repository.
Undo, written before the roll moves. Set each web app's image back to the Azure registry's last tag with acrUseManagedIdentityCreds true (infra/appservice.bicep, infra/render.bicep). That works for the week the Azure registry is kept after the switch, and it is deleted only after seven green rolls from ghcr.io (ADR-106).
DeployWorkflowTests.Each_image_is_pushed_to_GitHub_s_registry_as_well_as_Azure_s holds both pushes.
Addendum, 2026-10-25 (1.0.4.83): the registry card reads GitHub's registry
The registry card now reads both registries. Beside the Azure registry's catalogue it keeps, each hour, what GitHub's registry holds of the two images the workflows push since 1.0.4.77, read the way an anonymous docker pull reads it: a pull token for ghcr.io/stevestout/<image>, then its tag list, with no credential of the site's sent. A public package lists its tags and the highest v-numbered one; a package that is still private, or was never pushed, refuses the list, and the readout line says so rather than showing it empty. A package a workflow creates starts private, and GitHub's API offers no call that changes a package's visibility, so making the two public is a click in each package's settings (Package settings, Danger Zone, Change visibility, Public). Until that click the roll stays on the Azure registry, as this record's addendum of 1.0.4.77 says. GhcrPackagesTests holds the read: a public image's tags, a private one refused, and the anonymous pull token the only credential.
Addendum, 2026-10-25 (1.0.4.88): each roll pulls from GitHub's registry
The step that waited on the click is done. Read live at 21:18 CDT on 25 October, the registry card's anonymous read (1.0.4.83) listed both packages, theyard v1.0.4.83, 7 tags and theyard-render v1.0.4.83, 7 tags, which ghcr.io answers to an anonymous pull token only for a public package. From this version each roll sets the web app's image to ghcr.io/stevestout/theyard:v<N>, and the renderer's to ghcr.io/stevestout/theyard-render:v<N>, and turns acrUseManagedIdentityCreds off in the same write, because a public image needs no credential and none is stored; infra/appservice.bicep and infra/render.bicep say false, so a deployment of either template cannot put the identity's pull back. App Service starts the new container beside the old one and moves traffic only when it answers, so a pull that failed would leave the site on the version before, and Verify would turn the roll red.
The Azure registry still receives every push, so it holds the tag of the version just rolled, and the undo written in the addendum of 1.0.4.77 rolls back to that same version rather than to the last one before the switch. Two parts of the prompt's rung wait. Keep-ten does not move to ghcr.io today: it would be a new deletion, of package versions through GitHub's API, and the lane that shipped this was allowed none but one database; the Azure registry's own keep-ten, the owner's standing rule, runs after each roll as before. And the Azure registry is not stopped, because the undo needs it and it is deleted only after seven green rolls from ghcr.io (ADR-106). The registry card's table of what the Azure registry holds now says no web app runs either image, which is true; its readout line on GitHub's registry names what they run. DeployWorkflowTests.Each_roll_pulls_from_GitHub_s_registry_with_no_credential holds both workflows and both templates: red on the prior tree.
Addendum, 2026-11-17 (1.0.5.80): the Azure registry is retired
In plain words: the site has pulled its images from GitHub's registry since 1.0.4.88, and the Azure registry has only been kept as the way back. The condition this record set for deleting it, seven green rolls from ghcr.io, was met many times over, so the workflows stop pushing to it, the way back moves to GitHub's own previous tag, and the registry is deleted. It saves about $5 a month (Cost Management, 30 days to 15 November: "Basic Registry Unit" $5.00).
Undo, written before anything moves. Every version is still pushed to ghcr.io/stevestout/theyard:v<N> and ghcr.io/stevestout/theyard-render:v<N>, and GitHub keeps every tag, so the way back from a bad roll is the version before on ghcr.io, with no credential, the same write the roll makes:
az webapp config set -g RG-THEYARD-SS -n APP-THEYARD-ONE-SS-ZMNETJ67BN5H2 --linux-fx-version "DOCKER|ghcr.io/stevestout/theyard:v<previous>"
az webapp config set -g RG-THEYARD-SS -n APP-THEYARD-RENDER-SS-ZMNETJ67BN5H2 --linux-fx-version "DOCKER|ghcr.io/stevestout/theyard-render:v<previous>"
<previous> is the changelog's second line. That is the undo the addendum of 1.0.4.77 kept the Azure registry for, without the registry.
The count. gh run list --workflow deploy.yml from 1.0.4.88 (07:39 UTC on 26 October) reads 28 runs, 27 green; since 1.0.4.101 the gate calls Deploy and Deploy Render inside its own run, and 135 gate runs went green in the same span (read on 16 November). Every one of those rolls pulled from ghcr.io.
What goes. Deploy and Deploy Render no longer sign in to the Azure registry or push its tag, and the keep-ten step that pruned its manifests after each roll goes with it: GitHub's registry is free for a public package, so there is nothing to prune for money. The templates stop naming the registry, the site's settings drop its name, and the registry card reads GitHub's registry alone. The registry is deleted under ADR-106 once the next roll is green from ghcr.io alone.
Enforced by
Not machine-checked. Held by review.