Skip to content

fix(actions): publish through the REST API, not the gh CLI - #86

Merged
oto-macenauer-absa merged 2 commits into
masterfrom
fix/actions-without-gh-cli
Sep 5, 2026
Merged

fix(actions): publish through the REST API, not the gh CLI#86
oto-macenauer-absa merged 2 commits into
masterfrom
fix/actions-without-gh-cli

Conversation

@oto-macenauer-absa

Copy link
Copy Markdown
Collaborator

Closes #85

Problem

Both shared composite actions shelled out to gh for the release lookup, gh release upload --clobber and the repository_dispatch notify. gh is preinstalled on GitHub-hosted runners but is not part of the runner, so a self-hosted runner without it failed at the upload step, after the artifact had already been built.

Change

  • actions/lib/release.cjs (new) — release lookup, clobber-upload and notify via the Octokit client actions/github-script provides. Zero dependencies; CommonJS because github-script hands scripts a require. Uploads go to the release's own upload_url, so GitHub Enterprise upload hosts work without configuration.
  • Both action.ymls — upload and notify steps are now actions/github-script@v9.0.0 (SHA-pinned) loading that module. Consumer-controlled values still flow through env, never into the script body (Hardening: publish-single-page-docs interpolates step outputs directly into a run: block #55). The only run: steps left are npm ci and the entry point.
  • build-image.ymlGITHUB_TOKEN defaults to github.token when docs-token is omitted, so fetch-apps.js never falls back to gh in CI. The fallback itself now says what to do when gh is missing instead of printing failed: undefined.
  • READMEs / contract/DEPLOYMENT.md — "Runner requirements" sections.
  • actions/lib/release.selftest.js — pins the API calls and their order against a recording fake client (tag resolution order, delete-before-upload, upload URL/headers, error messages, non-404 errors propagate, notify warns and never fails). Part of npm run selftest, so CI's actions job runs it.

Behaviour change worth knowing

Previously any API error during the tag lookup (e.g. a 403 from a token without contents: write) was swallowed and surfaced as "no GitHub Release". A non-404 error now propagates with its real cause.

Verification

  • npm run selftest green (both actions + the new release checks)
  • Both manifests and the workflow parse with the same yaml package CI uses
  • No gh left outside comments in actions/**/action.yml
  • Not run against a live release: recommend one dry publish from a docs repo pinned at this commit before moving v1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PYtmxSeSXFg4wEXRcKCmAi

oto-macenauer-absa and others added 2 commits September 5, 2026 09:16
gh is preinstalled on GitHub-hosted runners but is not part of the runner, so
on a self-hosted runner without it both publishing actions failed at the upload
step, after the artifact had already been built. Every gh invocation — release
lookup, `gh release upload --clobber`, the repository_dispatch notify — now runs
through actions/github-script and the Octokit client it provides, in one shared
module, actions/lib/release.cjs. The runner needs nothing preinstalled beyond
bash for the two one-line run: steps; Node comes from setup-node.

Uploads go to the release's own upload_url rather than a hard-coded
uploads.github.com, so GitHub Enterprise hosts work as well. Consumer-controlled
values still flow through env, never into the script body (#55).

The reusable build workflow now defaults GITHUB_TOKEN to github.token when
docs-token is omitted, so fetch-apps.js never falls back to gh in CI; the
fallback itself now says what to do when gh is missing instead of printing
"failed: undefined".

release.selftest.js pins the API calls and their order against a recording fake
client and is part of `npm run selftest`.

Closes #85

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PYtmxSeSXFg4wEXRcKCmAi
The reasoning belongs in the comment itself; a tracker reference is one more
thing that goes stale.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PYtmxSeSXFg4wEXRcKCmAi
@oto-macenauer-absa
oto-macenauer-absa merged commit 3bfcc6e into master Sep 5, 2026
9 checks passed
@oto-macenauer-absa
oto-macenauer-absa deleted the fix/actions-without-gh-cli branch September 5, 2026 07:40
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.

Shared actions must not depend on the gh CLI (self-hosted runners)

1 participant