Upload images to a GitHub PR description or comment using a shared gist as image hosting. Use when the user wants to add plots, screenshots, or other images to a PR.
GitHub's API doesn't support direct image uploads to PR descriptions. This skill uses a shared gist as persistent image hosting.
Use the existing gist for all image uploads:
a7a894454779b8c3a27906f0e8d026fbtbroadleyhttps://gist.github.com/a7a894454779b8c3a27906f0e8d026fb.gitGIST_ID="a7a894454779b8c3a27906f0e8d026fb"
GIST_DIR="/tmp/gist-images/${GIST_ID}"
if [ -d "$GIST_DIR" ]; then
cd "$GIST_DIR" && git pull
else
mkdir -p /tmp/gist-images
gh gist clone "$GIST_ID" "$GIST_DIR"
cd "$GIST_DIR"
fi
Use descriptive filenames. If updating existing files, make them writable first (gist files from gh gist clone may be read-only):
chmod u+w "$GIST_DIR"/*.png 2>/dev/null
cp /path/to/image.png "$GIST_DIR/descriptive_name.png"
cd "$GIST_DIR"
git add -A
git commit -m "Add images for PR #<number>"
git push
GitHub caches gist raw URLs aggressively. Pin URLs to a specific commit to ensure updated images are shown:
COMMIT=$(cd "$GIST_DIR" && git rev-parse HEAD)