Skip to content
Merged
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
14 changes: 11 additions & 3 deletions docs/GITHUB_RELEASE_WEBHOOK_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Status

**Stage:** Phase A complete (2026-07-28). No GitHub organization webhook,
Cloudflare secret, or production release configuration has been activated
yet. Phases B–E remain open.
**Stage:** Phase B complete (2026-07-28). No GitHub organization webhook,
Cloudflare webhook secret, or production activation yet. Phases C–E remain
open.

**Phase A reconciliation (2026-07-28):** `@pegma/webhooks` is pinned to
`@pegma/storage-core@0.4.0` (commit `1e5ef0732c3595ea82cb80394cf55cd9a0442318`).
Expand All @@ -21,6 +21,14 @@ packages is separate host debt, not a webhook-handler prerequisite. The
vendored package README carries only the MIT copyright line for
RetireGolden, LLC — no consumer-migration or commercial planning text.

**Phase B reconciliation (2026-07-28):** `POST /api/webhooks/github/releases`
authenticates raw-body HMAC-SHA256, allowlists organization `309286193` and
explicit repository IDs, records deliveries in `@pegma/webhooks` (`source:
"github"`), and projects current stable releases into the
`componentReleases` collection. Draft/prerelease events are acknowledged
without projection. No payload fields cross the release codec. Read API, UI,
reconciliation, secret install, and organization webhook activation remain.

**Goal:** Keep the public release version and release date for Pegma
components current on pegma.dev without a content commit, Pages build, or site
deployment for each release.
Expand Down
4 changes: 3 additions & 1 deletion docs/PROJECT_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,6 @@ with a source link where not. Decide in Phase 3.
content commit or Pages deploy per release — see
`docs/GITHUB_RELEASE_WEBHOOK_PLAN.md`. **Phase A (2026-07-28):** vendored
`@pegma/webhooks` artifact aligned to Storage Core `0.4.0` and proven over
memory + D1; handler, read API, UI, reconciliation, and activation remain.
memory + D1. **Phase B (2026-07-28):** signed GitHub release webhook
handler + current-release projection. Read API, UI, reconciliation, and
activation remain.
3 changes: 3 additions & 0 deletions worker/.dev.vars.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Local secrets for `wrangler dev` (never commit real values).
# DATADOG_API_KEY=
# DATADOG_SITE=us5.datadoghq.com
# IDENTITY_EMAIL_CODE_SECRET_BASE64=
# RESEND_API_KEY=
# GITHUB_WEBHOOK_SECRET=
6 changes: 6 additions & 0 deletions worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ public acknowledgement endpoint.
- `POST /api/identity/email-code/sign-in/options|verify` — enumeration-safe
fallback sign-in.
- `POST /api/identity/logout` — server-side revocation and cookie expiry.
- `POST /api/webhooks/github/releases` — authenticated GitHub organization
release webhook. Requires managed secret `GITHUB_WEBHOOK_SECRET` plus vars
`GITHUB_ORGANIZATION_ID` and `GITHUB_ALLOWED_REPOSITORY_IDS`. Invalid traffic
has no storage effect; stable releases project into the D1-backed
`componentReleases` collection through `@pegma/webhooks`. Do not configure
the GitHub organization webhook until Phase E activation.

Example body:

Expand Down
63 changes: 63 additions & 0 deletions worker/src/component-release.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
defineCollection,
type CollectionDefinition,
type EntityKey,
type StoredRecord,
type StoredValue,
} from '@pegma/storage-core';

/** Public current-stable release facts for one allowlisted repository. */
export interface ComponentRelease {
readonly repositoryId: string;
readonly repositoryName: string;
readonly releaseId: string;
readonly tagName: string;
readonly publishedAt: string;
readonly releaseUrl: string;
readonly observedAt: string;
}

const RELEASE_PARTITION = 'current';

type EncodedComponentRelease = Record<keyof ComponentRelease, StoredValue>;

function encodeComponentRelease(
value: ComponentRelease,
): EncodedComponentRelease {
return {
repositoryId: value.repositoryId,
repositoryName: value.repositoryName,
releaseId: value.releaseId,
tagName: value.tagName,
publishedAt: value.publishedAt,
releaseUrl: value.releaseUrl,
observedAt: value.observedAt,
};
}

function decodeComponentRelease(record: StoredRecord): ComponentRelease {
return {
repositoryId: String(record['repositoryId'] ?? ''),
repositoryName: String(record['repositoryName'] ?? ''),
releaseId: String(record['releaseId'] ?? ''),
tagName: String(record['tagName'] ?? ''),
publishedAt: String(record['publishedAt'] ?? ''),
releaseUrl: String(record['releaseUrl'] ?? ''),
observedAt: String(record['observedAt'] ?? ''),
};
}

export function componentReleaseKey(repositoryId: string): EntityKey {
return { partition: RELEASE_PARTITION, id: repositoryId };
}

export function componentReleaseCollection(): CollectionDefinition<ComponentRelease> {
return defineCollection({
name: 'componentReleases',
key: (value) => componentReleaseKey(value.repositoryId),
codec: {
encode: encodeComponentRelease,
decode: decodeComponentRelease,
},
});
}
Loading