Skip to content

Action: fork PRs get the diff in the run summary; only update our own comment - #110

Merged
MarkPhamm merged 2 commits into
mainfrom
fix/103-action-comment
Nov 12, 2026
Merged

MarkPhamm merged 2 commits into
mainfrom
fix/103-action-comment

Conversation

@MarkPhamm

Copy link
Copy Markdown
Owner

Fixes #103

Cause (action.yml, Comment on pull request)

  • Fork PRs get a read-only GITHUB_TOKEN, so the POST got a 403 and failed the job.
  • The existing-comment lookup matched any comment starting with the marker, whoever wrote it.
  • --paginate --jq runs per page, so matches on two pages gave two ids and a broken PATCH URL.

Fix

  • When the PR's head repo isn't this repo, write the diff to $GITHUB_STEP_SUMMARY, log a notice, and skip the comment. No pull_request_target needed.
  • Only match comments by the token's user: gh api user for a PAT, else github-actions[bot] (the default token can't read /user).
  • Take the first id from all pages.
  • docs/github-action.md notes the fork behaviour.

Verified. Ran the step's script from action.yml against a fake gh that serves fixture comment pages:

case before after
only a human's marker comment PATCHes the human's comment 1 posts a new comment
bot comments on pages 2 and 3 id 22\n33, broken PATCH URL PATCHes 22
fork PR tries to PATCH (403 in real life) summary written, notice, exit 0

This PR's own erd.yml run exercises the same-repo path for real. The fork path is only covered by the fake.

…comment.

Fork PRs get a read-only token, so posting the comment failed the job; the diff
now goes to the run summary. The lookup matched a marker comment by anyone, and
--jq ran per page, so two matches broke the PATCH URL.
gh prints the error body on stdout, so the old fallback put it into the jq
filter and the step failed on same-repo PRs.
@github-actions

Copy link
Copy Markdown

Schema changes: origin/main → working tree

No schema changes.

Interactive diagram with changes highlighted: download the erd artifact from this run. Generated by qdbd.

@MarkPhamm
MarkPhamm merged commit 707c592 into main Nov 12, 2026
13 checks passed
@MarkPhamm
MarkPhamm deleted the fix/103-action-comment branch November 12, 2026 08:41
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.

GitHub Action: PR comment step fails on fork PRs and matches anyone's comment

1 participant