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
1 change: 0 additions & 1 deletion .github/workflows/container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
- "pkgs/identity/**"
- "pkgs/lab-ops-hub/container-image.nix"
- "pkgs/lab-ops-hub/container/**"
- "pkgs/lab-ops-hub/wrangler.jsonc"
- "pkgs/generic-containers/**"
- "lib/default.nix"
- "flake.nix"
Expand Down
138 changes: 138 additions & 0 deletions .github/workflows/lab-ops-hub-promote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Lab Ops Hub Worker Version promotion

on:
workflow_dispatch:
inputs:
upload_run_id:
description: "Successful trusted upload workflow run ID containing the Worker Version receipt"
required: true
type: string

permissions:
actions: read
contents: read

concurrency:
group: lab-ops-hub-cloudflare-release
cancel-in-progress: false

jobs:
promote:
if: github.repository == 'developing-today/code' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
timeout-minutes: 20
environment: lab-ops-hub-cloudflare-release
steps:
- name: Validate upload run ID
env:
UPLOAD_RUN_ID: ${{ inputs.upload_run_id }}
run: |
set -euo pipefail
[[ "$UPLOAD_RUN_ID" =~ ^[1-9][0-9]{0,19}$ ]] || {
echo "::error::upload_run_id must be a numeric GitHub Actions run ID, not a Worker Version UUID"
exit 2
}

- name: Checkout the dispatched main commit for trusted receipt validation
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.sha }}

- name: Set up Node 24.22.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: 24.22.0

- name: Download the receipt from the selected upload run
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: lab-ops-hub-version-receipt
run-id: ${{ inputs.upload_run_id }}
github-token: ${{ github.token }}
path: ${{ runner.temp }}/loh-receipt

- name: Verify the exact successful trusted upload run
id: receipt
env:
GH_TOKEN: ${{ github.token }}
UPLOAD_RUN_ID: ${{ inputs.upload_run_id }}
run: |
set -euo pipefail
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$UPLOAD_RUN_ID" > "$RUNNER_TEMP/loh-upload-run.json"
node pkgs/lab-ops-hub/release-tools/release-safety.mjs trust-receipt \
"$RUNNER_TEMP/loh-receipt/receipt.json" \
"$RUNNER_TEMP/loh-upload-run.json" >> "$GITHUB_OUTPUT"

- name: Checkout the exact uploaded source commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ steps.receipt.outputs.source_sha }}

- name: Install pinned cf and Wrangler toolchain
working-directory: pkgs/lab-ops-hub
run: |
npm ci --prefix release-tools --no-audit --no-fund
test ! -e node_modules
ln -s release-tools/node_modules node_modules
node -e 'const p=require("./release-tools/package-lock.json"); if(p.packages["node_modules/cf"].version!=="1.0.0-rc.1" || p.packages["node_modules/wrangler"].version!=="4.163.0") process.exit(1)'
test "$(./node_modules/.bin/cf --version)" = "1.0.0-rc.1"

- name: Rebuild the uploaded source and verify configuration parity
working-directory: pkgs/lab-ops-hub
run: |
./node_modules/.bin/cf build
node release-tools/verify-build.mjs
node --test release-tools/release-safety.test.mjs

- name: Verify receipt baseline, v2 metadata, and exact image pin
working-directory: pkgs/lab-ops-hub
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }}
BASELINE_VERSION_ID: ${{ steps.receipt.outputs.baseline_version_id }}
VERSION_ID: ${{ steps.receipt.outputs.version_id }}
VERSION_TAG: ${{ steps.receipt.outputs.version_tag }}
run: |
set -euo pipefail
test -n "$CLOUDFLARE_ACCOUNT_ID" || { echo "::error::missing environment variable CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID"; exit 1; }
test -n "$CLOUDFLARE_API_TOKEN" || { echo "::error::missing protected environment secret CLOUDFLARE_LAB_OPS_HUB_API_TOKEN"; exit 1; }
./node_modules/.bin/cf workers deployments list --worker lab-ops-hub > "$RUNNER_TEMP/loh-current-deployments.json"
node release-tools/release-safety.mjs verify-current "$RUNNER_TEMP/loh-current-deployments.json" "$BASELINE_VERSION_ID"
./node_modules/.bin/cf workers versions get "$BASELINE_VERSION_ID" --worker lab-ops-hub > "$RUNNER_TEMP/loh-baseline-version.json"
node release-tools/release-safety.mjs verify-version "$RUNNER_TEMP/loh-baseline-version.json" "$BASELINE_VERSION_ID"
./node_modules/.bin/cf workers versions get "$VERSION_ID" --worker lab-ops-hub > "$RUNNER_TEMP/loh-version.json"
node release-tools/release-safety.mjs verify-version "$RUNNER_TEMP/loh-version.json" "$VERSION_ID" "$VERSION_TAG"
node release-tools/release-safety.mjs deployment-versions "$RUNNER_TEMP/loh-receipt/receipt.json" "$RUNNER_TEMP/loh-versions.json"

- name: Recheck the serving baseline immediately before promotion
working-directory: pkgs/lab-ops-hub
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }}
BASELINE_VERSION_ID: ${{ steps.receipt.outputs.baseline_version_id }}
run: |
set -euo pipefail
./node_modules/.bin/cf workers deployments list --worker lab-ops-hub > "$RUNNER_TEMP/loh-final-baseline.json"
node release-tools/release-safety.mjs verify-current "$RUNNER_TEMP/loh-final-baseline.json" "$BASELINE_VERSION_ID"

- name: Promote the receipt-bound version to 100%
working-directory: pkgs/lab-ops-hub
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }}
run: >-
./node_modules/.bin/cf workers deployments create
--worker lab-ops-hub
--strategy percentage
--versions @${{ runner.temp }}/loh-versions.json

- name: Confirm the promoted version is the only version serving
working-directory: pkgs/lab-ops-hub
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }}
VERSION_ID: ${{ steps.receipt.outputs.version_id }}
run: |
set -euo pipefail
./node_modules/.bin/cf workers deployments list --worker lab-ops-hub > "$RUNNER_TEMP/loh-promoted-deployments.json"
node release-tools/release-safety.mjs verify-deployed "$RUNNER_TEMP/loh-promoted-deployments.json" "$VERSION_ID"
103 changes: 103 additions & 0 deletions .github/workflows/lab-ops-hub-worker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Lab Ops Hub Worker Version upload

on:
workflow_dispatch:

permissions:
actions: read
contents: read

concurrency:
group: lab-ops-hub-cloudflare-release
cancel-in-progress: false

jobs:
upload:
if: github.repository == 'developing-today/code' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
timeout-minutes: 20
environment: lab-ops-hub-cloudflare-release
steps:
- name: Checkout the dispatched main commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.sha }}

- name: Set up Node 24.22.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: 24.22.0

- name: Install pinned cf and Wrangler toolchain
working-directory: pkgs/lab-ops-hub
run: |
npm ci --prefix release-tools --no-audit --no-fund
test ! -e node_modules
ln -s release-tools/node_modules node_modules
node -e 'const p=require("./release-tools/package-lock.json"); if(p.packages["node_modules/cf"].version!=="1.0.0-rc.1" || p.packages["node_modules/wrangler"].version!=="4.163.0") process.exit(1)'
test "$(./node_modules/.bin/cf --version)" = "1.0.0-rc.1"

- name: Build Build Output v1 and verify Wrangler parity
working-directory: pkgs/lab-ops-hub
run: |
./node_modules/.bin/cf build
node release-tools/verify-build.mjs
node --test release-tools/release-safety.test.mjs

- name: Dry-run Worker Version upload
working-directory: pkgs/lab-ops-hub
run: >-
./node_modules/.bin/cf workers versions create
--prebuilt
--worker lab-ops-hub
--tag "git-${GITHUB_SHA::12}"
--message "git ${GITHUB_SHA}"
--dry-run

- name: Read the exact serving baseline and verify v2 plus the image pin
id: baseline
working-directory: pkgs/lab-ops-hub
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }}
run: |
set -euo pipefail
test -n "$CLOUDFLARE_ACCOUNT_ID" || { echo "::error::missing environment variable CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID"; exit 1; }
test -n "$CLOUDFLARE_API_TOKEN" || { echo "::error::missing protected environment secret CLOUDFLARE_LAB_OPS_HUB_API_TOKEN"; exit 1; }
./node_modules/.bin/cf workers deployments list --worker lab-ops-hub > "$RUNNER_TEMP/loh-deployments.json"
baseline_id=$(node release-tools/release-safety.mjs baseline-id "$RUNNER_TEMP/loh-deployments.json")
./node_modules/.bin/cf workers versions get "$baseline_id" --worker lab-ops-hub > "$RUNNER_TEMP/loh-baseline-version.json"
node release-tools/release-safety.mjs verify-version "$RUNNER_TEMP/loh-baseline-version.json" "$baseline_id"
echo "baseline_version_id=$baseline_id" >> "$GITHUB_OUTPUT"

- name: Upload Worker Version without promoting it
id: upload
working-directory: pkgs/lab-ops-hub
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }}
run: |
set -euo pipefail
./node_modules/.bin/cf workers versions create \
--prebuilt \
--worker lab-ops-hub \
--tag "git-${GITHUB_SHA::12}" \
--message "git ${GITHUB_SHA}" \
> "$RUNNER_TEMP/loh-upload.json"
version_id=$(node release-tools/release-safety.mjs upload-id "$RUNNER_TEMP/loh-upload.json")
./node_modules/.bin/cf workers versions get "$version_id" --worker lab-ops-hub > "$RUNNER_TEMP/loh-version.json"
node release-tools/release-safety.mjs verify-version "$RUNNER_TEMP/loh-version.json" "$version_id" "git-${GITHUB_SHA::12}"
mkdir -p "$RUNNER_TEMP/loh-receipt"
node release-tools/release-safety.mjs receipt \
"$RUNNER_TEMP/loh-upload.json" \
"$RUNNER_TEMP/loh-version.json" \
"${{ steps.baseline.outputs.baseline_version_id }}" \
"$RUNNER_TEMP/loh-receipt/receipt.json"

- name: Save the exact upload receipt for a later promotion
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: lab-ops-hub-version-receipt
path: ${{ runner.temp }}/loh-receipt/receipt.json
if-no-files-found: error
retention-days: 14
28 changes: 25 additions & 3 deletions .github/workflows/lab-ops-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

- name: Set up Node
uses: actions/setup-node@v7
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: 24
node-version: 24.22.0

- name: Set up Python
uses: actions/setup-python@v7
Expand All @@ -68,3 +68,25 @@ jobs:
- name: Run both crawl-validator suites
working-directory: pkgs/lab-ops-hub
run: npm test

- name: Install pinned Worker release toolchain
working-directory: pkgs/lab-ops-hub
run: |
npm ci --prefix release-tools
ln -s release-tools/node_modules node_modules

- name: Build and verify Build Output v1 parity
working-directory: pkgs/lab-ops-hub
run: |
./node_modules/.bin/cf build
node release-tools/verify-build.mjs

- name: Dry-run Worker Version upload
working-directory: pkgs/lab-ops-hub
run: >-
./node_modules/.bin/cf workers versions create
--prebuilt
--worker lab-ops-hub
--tag git-offlinecheck
--message offline-check
--dry-run
7 changes: 6 additions & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ let
labOpsHubDeploy = pkgs.callPackage ../pkgs/lab-ops-hub/deploy.nix {
inherit labOpsHub;
};
labOpsHubImagePush = pkgs.callPackage ../pkgs/lab-ops-hub/image-push.nix {
inherit labOpsHub;
};
cfContainerHello = pkgs.callPackage ../pkgs/cf-container-hello/package.nix { };
cfContainerHelloDeploy = pkgs.callPackage ../pkgs/cf-container-hello/deploy.nix {
inherit cfContainerHello;
Expand Down Expand Up @@ -781,6 +784,7 @@ let
coldStoreRehydratorDeploy
labOpsHub
labOpsHubDeploy
labOpsHubImagePush
cfContainerHello
cfContainerHelloDeploy
queueTransportAlert
Expand Down Expand Up @@ -865,7 +869,8 @@ let
pkarr-deploy = mkApp pkarrDeploy "Deploy the pkarr Worker via the cf versions flow (needs Bitwarden and sops access)";
developing-today-backup-deploy = mkApp developingTodayBackupDeploy "Deploy the developing-today-backup Worker (github-backup webhook receiver) via the wrangler versions flow (needs Bitwarden and sops access)";
cold-store-rehydrator-deploy = mkApp coldStoreRehydratorDeploy "Deploy the cold-store-rehydrator Worker from its flake bundle via the wrangler versions flow (needs Bitwarden and sops access)";
lab-ops-hub-deploy = mkApp labOpsHubDeploy "Deploy the lab-ops-hub Worker and push its crawler container image as one command (needs Bitwarden and sops access)";
lab-ops-hub-image-push = mkApp labOpsHubImagePush "Build and push the Lab Ops Hub crawler container image only (needs Bitwarden and sops access); Worker releases use the GHA cf Versions workflow";
lab-ops-hub-deploy = mkApp labOpsHubDeploy "Legacy Lab Ops Hub operator recovery: build/push the pinned crawler image and deploy the Worker with pinned Wrangler (needs Bitwarden, sops, and Cloudflare registry access)";
cf-container-hello-deploy = mkApp cfContainerHelloDeploy "Deploy the cf-container-hello Worker from its flake package (needs Bitwarden and sops access)";
queue-transport-alert-deploy = mkApp queueTransportAlertDeploy "Deploy the queue-transport-alert Worker (broker outage alert, code#6369) from its flake package via the cf versions flow (needs Bitwarden and sops access)";
message-bridge-deploy = mkApp messageBridgeDeploy "Deploy the message-bridge Worker (Claude custom connector that sends and receives messages, plus history page) through the cf versions flow (tagged version, then deployment) and set its access token; --code-only uploads code with Cloudflare env vars (CI), --deploy-version <id> rolls back, --print-urls prints the connector URL (needs Bitwarden and sops access)";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/deploy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let
coldStoreRehydratorDeploy = callPackage ../../pkgs/cold-store-reaper/worker/deploy.nix {
coldStoreRehydratorBundle = callPackage ../../pkgs/cold-store-reaper/worker/package.nix { };
};
labOpsHubDeploy = callPackage ../../pkgs/lab-ops-hub/deploy.nix {
labOpsHubImagePush = callPackage ../../pkgs/lab-ops-hub/image-push.nix {
labOpsHub = callPackage ../../pkgs/lab-ops-hub/package.nix { };
};
cfContainerHelloDeploy = callPackage ../../pkgs/cf-container-hello/deploy.nix {
Expand Down
10 changes: 6 additions & 4 deletions pkgs/deploy/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
pkarrDeploy,
developingTodayBackupDeploy,
coldStoreRehydratorDeploy,
labOpsHubDeploy,
labOpsHubImagePush,
cfContainerHelloDeploy,
queueTransportAlertDeploy,
messageBridgeDeploy,
Expand Down Expand Up @@ -193,9 +193,11 @@
class = "cloudflare";
};

lab-ops-hub = {
package = labOpsHubDeploy;
entryPoint = "bin/lab-ops-hub-deploy";
# Keep the crawler image publisher as a separate operator action. The
# Worker's cf Version upload and promotion live in GitHub Actions.
lab-ops-hub-image = {
package = labOpsHubImagePush;
entryPoint = "bin/lab-ops-hub-image-push";
args = [ ];
environment = { };
secrets = [ ]; # resolved by the deploy app itself at deploy time
Expand Down
1 change: 1 addition & 0 deletions pkgs/lab-ops-hub/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.cloudflare/
Loading