Upload images to GitHub Issue/PR comments and insert them with fixed width.
Works with both GitHub.com and GitHub Enterprise.
- gh CLI (authenticated)
- playwright-cli (browser mode only, not needed for
--releasemode)
brew tap atani/tap # first time only
brew install gh-attach
# First run: login to GitHub in browser
gh-attach --issue 1 --image ./test.png --headedgh extension install atani/gh-attach
# Use as: gh attach
gh attach --issue 123 --image ./screenshot.png- Install dependencies:
# gh CLI (if not installed)
brew install gh
gh auth login
# playwright-cli
npm install -g @playwright/mcp- Add to PATH:
# Option A: Symlink
ln -s /path/to/gh-attach/bin/gh-attach /usr/local/bin/gh-attach
# Option B: Add to PATH
export PATH="/path/to/gh-attach/bin:$PATH"Login to GitHub in the browser session:
gh-attach --issue 1 --image ./test.png --headed
# Browser opens → Login to GitHub → Session is saved for future usegh-attach --issue 123 --image ./screenshot.pnggh-attach --issue 123 --image ./e2e.png --body "E2E test result:"gh-attach --issue 123 \
--image ./before.png \
--image ./after.png \
--body 'Before: <!-- gh-attach:IMAGE:1 -->
After: <!-- gh-attach:IMAGE:2 -->'gh-attach --issue 123 --image ./screenshot.png --releasegh-attach --issue 123 --image ./result.png --body-file report.mdControl where images are inserted in the comment body:
| Placeholder | Description |
|---|---|
<!-- gh-attach:IMAGE --> |
Single image (or first image) |
<!-- gh-attach:IMAGE:1 --> |
First image (numbered) |
<!-- gh-attach:IMAGE:2 --> |
Second image |
<!-- gh-attach:IMAGE:N --> |
N-th image |
If no placeholder is present, images are appended to the end.
| Option | Required | Default | Description |
|---|---|---|---|
--issue <number> |
Yes | - | Issue or PR number |
--image <path> |
Yes | - | Image file (can be repeated) |
--repo <owner/repo> |
No | current repo | Target repository |
--width <px> |
No | 800 | Image width in pixels |
--body <text> |
No | - | Comment body text |
--body-file <path> |
No | - | Read body from file |
--host <host> |
No | auto-detected | GitHub host (for Enterprise) |
--release |
No | - | Use GitHub Releases API (no browser needed) |
--release-tag <tag> |
No | gh-attach-assets | Release tag for uploads |
--headed |
No | - | Show browser window (browser mode only) |
- Create a comment with placeholder(s)
- Open GitHub in browser via playwright-cli
- Upload image(s) using GitHub's native upload
- Extract the uploaded URL(s)
- Update the comment with
<img>tags
- PR comments use the same API as issue comments (use PR number)
- Images are inserted as HTML:
<img src="..." width="800" alt="..."> - Browser session is persisted, so login is only needed once
- Use
--headedto debug or when login is required