Fix playwright comment & Claude PR workflows (#2043)
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> **Workflows**
>
> - Updates `playwright-comment.yml` to reliably find the associated PR,
including forks: extracts `head_branch`/`head_repository`, logs context,
and falls back to `pulls.list` with `head: "owner:branch"` when commit
association lookup returns no PR.
> - Revises `claude-pr-review.yml` to use `pull_request_target`,
restricts execution via `author_association` (`OWNER`/`MEMBER`), and
checks out the PR head repo/ref explicitly for fork safety.
> - Configures the Claude action with `github_token` (OIDC bypass),
`allowed_non_write_users`, and disables `track_progress`;
trims/clarifies review prompt guidelines.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8267093820bd968db57167a37b2d2570e94fe010. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes the Playwright comment workflow so it reliably finds the
associated PR, including PRs from forks. Updates the Claude PR Review
workflow to run safely on forked PRs and only for org members.
- **Bug Fixes**
- Playwright: add fallback search by head owner:branch; better logging
(SHA, branch, owner) to post to the right PR.
- Claude PR Review: switch to pull_request_target with OWNER/MEMBER
filter; checkout fork head; disable progress; drop id-token.
<sup>Written for commit 8267093820bd968db57167a37b2d2570e94fe010.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR restores the fallback mechanism for finding PR numbers from
forked repositories. The previous commit (41a46a9b) inadvertently removed
the fork PR detection logic, breaking Playwright comment posting for
external contributors. This fix re-introduces a two-method approach:
- **Method 1**: Uses `listPullRequestsAssociatedWithCommit` (works for
same-repo PRs)
- **Method 2**: Falls back to `pulls.list` with `head: "owner:branch"`
when Method 1 fails (handles fork PRs)
The change extracts additional context (`head_branch`,
`head_repository.owner.login`) from the workflow run payload and adds
improved logging for debugging PR lookups.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no risk
- The change restores critical functionality that was accidentally
removed in the previous commit. The implementation is correct,
well-commented, and follows GitHub Actions best practices. No logic
errors, security issues, or breaking changes detected.
- No files require special attention
<h3>Important Files Changed</h3>
| Filename | Overview |
|----------|----------|
| .github/workflows/playwright-comment.yml | Added fallback logic for
fork PRs by searching head branch when commit lookup fails |
</details>
<h3>Sequence Diagram</h3>
```mermaid
sequenceDiagram
participant CI as CI Workflow
participant WR as Workflow Run Event
participant GH as GitHub API
participant Script as PR Lookup Script
CI->>WR: Completes (triggers workflow_run)
WR->>Script: Provides head_sha, head_branch, head_repository
Script->>Script: Extract sha, headBranch, headRepoOwner
Script->>GH: listPullRequestsAssociatedWithCommit(sha)
alt Commit found (same-repo PRs)
GH-->>Script: Returns PR data
Script->>Script: Set PR number output
else No PR found
Script->>Script: Check if headRepoOwner & headBranch exist
alt Fork PR fallback
Script->>GH: pulls.list(head: "owner:branch")
GH-->>Script: Returns PR from fork
Script->>Script: Set PR number output
else Still no PR
Script->>Script: Set empty output (skip commenting)
end
end
Script->>WR: Output PR number or empty
alt PR found
WR->>Script: Download artifacts & generate comment
Script->>GH: Post/update PR comment
else No PR
WR->>WR: Skip remaining steps
end
```
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
正在显示
请
注册
或者
登录
后发表评论