pr-unified-diff-action
April 22, 2026 ยท View on GitHub
GitHub Action to get the unified diff of a pull request.
This is a JavaScript Action port of suzuki-shunsuke/go-pr-diff.
It first tries the GitHub REST API, and falls back to git commands if the API fails (e.g. when the diff is too large).
The diff is written to a file so that large diffs are not truncated by the GitHub Actions output size limit.
How It Works
- The action calls
GET /repos/{owner}/{repo}/pulls/{number}withAccept: application/vnd.github.v3.diffto get the raw diff. - If the API call fails, the action falls back to
git:- Fetch the base SHA, head SHA, and the base repository's clone URL via the pulls API.
- Compute the merge-base SHA via the compare API.
git fetch --depth 1 <base_clone_url> <merge_base>and<head_sha>.git diff <merge_base> <head_sha>and capture stdout.