tooling: attach screenshots to a PR from the CLI (scripts/pr-image.sh)#215
Merged
Conversation
gh can't upload images into GitHub markdown (that's the web UI's private upload endpoint). This parks a PNG on a dedicated orphan 'assets' branch via git plumbing (no working-tree/index/HEAD change, never in a PR diff) and prints paste-ready  markdown that renders inline. Appends (old images survive), replaces same-named files, and refuses a private repo whose raw URLs wouldn't render. Documented in docs/dev/driving-the-app.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We keep hitting the same wall:
ghcan't upload an image into GitHub markdown, so screenshots don't make it onto a PR from a headless/CLI session. This adds a small, reusable fix.What
scripts/pr-image.sh <image> ...parks the PNG(s) on a dedicated orphanassetsbranch and prints paste-ready markdown:GitHub renders
for any URL returning image bytes, and this is a public repo, so its ownraw.githubusercontent.comserves them.Why it's safe
hash-object→mktree→commit-tree→push) — never touches your working tree, index, or HEAD, and never switches branches.assetsbranch is orphan: never merged, never in a PR diff.Proof it works
Already used it to land the before/after review-card screenshots on #214 (the dapp-origin PR). shellcheck-clean; self-tested the append path.
Documented in
docs/dev/driving-the-app.md→ "Attaching a screenshot to a PR".