Skip to content

feat: build.script + build.aptPackages for pre-upload transform - #3

Merged
baladithyab merged 2 commits into
mainfrom
feat/build-script
May 28, 2026
Merged

baladithyab merged 2 commits into
mainfrom
feat/build-script

Conversation

@baladithyab

Copy link
Copy Markdown
Owner

Companion to baladithyab/baladithyab.github.io#38. Adds two optional pre-upload steps to the reusable workflow.

What it does

Reads build.aptPackages and build.script from web.codeseys.json. If aptPackages is set, installs them. If script is set, runs it.

Why

The architecture currently assumes upload-ready files are committed to the source repo. This forces inefficient choices:

  • 72MB galaxy.mp4 textures committed as-is when 13MB optimized would be enough
  • C++ source compiled offline because there's nowhere to compile it in CI
  • Notebooks pre-converted to HTML manually

With build-step support, manifests can declare 'how to make these files', and CI does it.

Example manifest

{
  "build": {
    "ci": true,
    "workflow": ".github/workflows/build-web-asset.yml",
    "aptPackages": ["ffmpeg"],
    "script": "scripts/optimize-textures.sh"
  }
}

Back-compat

Both fields are optional; manifests without them skip the steps entirely. All 3 existing repos keep working unchanged.

🤖 Generated with the help of Claude

The Mint OIDC token step calls the runner-local token broker
($ACTIONS_ID_TOKEN_REQUEST_URL) and exchanges the broker token
for a short-lived ID token scoped to the configured audience.
Failures are non-fatal: if OIDC env vars aren't present (e.g.
caller forgot 'permissions: id-token: write'), we fall back to
the static PROJECT_EMBED_UPLOAD_TOKEN bearer.

The Upload step now picks BEARER from OIDC if available, else
static bearer, else fails with explicit guidance.

Caller workflows must include in their permissions block:

    permissions:
      contents: write
      pull-requests: write
      id-token: write

Static bearer remains supported for repos that don't (or can't)
use OIDC, e.g. manual upload scripts.
Two new steps insert between manifest read and source staging:

1. **Install apt packages** — reads `build.aptPackages` from the
   manifest and runs `apt-get install -y`. Lets manifests declare
   non-default tools (ffmpeg, emscripten, cmake, etc.) without
   requiring caller workflows to pre-install them.

2. **Run build.script** — if the manifest declares `build.script`,
   chmod +x and execute it from the repo root. The script gets
   `EMBED_SLUG`, `EMBED_VERSION`, `EMBED_SOURCE_DIR` env vars.
   It's expected to write its outputs into `source-dir` so the
   subsequent stage step picks them up.

Use cases:
- Optimize textures: `ffmpeg` re-encode of large MP4s before upload
- Compile WASM: `emcc src/foo.cpp -o assets/foo.html` for C++ → web
- Convert notebooks: `jupyter nbconvert --to html`
- TypeScript builds, Cargo wasm-pack, etc.

Both steps are no-ops when the manifest fields are absent, so
existing repos stay back-compat.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 77ac488e4d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

contents: write
pull-requests: write
# Mint OIDC tokens. Required for the OIDC auth path.
id-token: write

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve static-token callers that omit id-token

Existing callers that follow this repo's documented reusable-workflow job permissions grant only contents: write and pull-requests: write; in GitHub's reusable-workflow permission model, the called workflow can only downgrade the caller job's token, so adding id-token: write here exceeds the caller's allowed permissions instead of merely making OIDC optional. Those runs fail before reaching the new fallback logic, so repos still using PROJECT_EMBED_UPLOAD_TOKEN are broken unless every caller is updated to include id-token: write.

Useful? React with 👍 / 👎.

@baladithyab
baladithyab merged commit e7c8cdc into main May 28, 2026
@baladithyab
baladithyab deleted the feat/build-script branch May 28, 2026 04:38
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.

1 participant