Fix pull request secret scanning by using GITHUB_HEAD_REF to scan PR commits#89
Fix pull request secret scanning by using GITHUB_HEAD_REF to scan PR commits#89Copilot wants to merge 3 commits into
Conversation
Co-authored-by: DariuszPorowski <3431813+DariuszPorowski@users.noreply.github.com>
|
@copilot perform a few tests on |
Verified ✓ Both approaches produce identical SHA values when they work. Test Results:
Key Finding:
|
|
@copilot under checks, runs show |
Co-authored-by: DariuszPorowski <3431813+DariuszPorowski@users.noreply.github.com>
Fixed in 8e37582. The issue was
Now using |
The action fails on pull requests with
fatal: ambiguous argument 'refs/remotes/pull/123/merge': unknown revision or path not in the working tree.Changes
refs/remotes/origin/${GITHUB_HEAD_REF}to get the actual PR head commit instead ofgit rev-list --no-merges -n 1 "refs/remotes/pull/${GITHUB_REF_NAME}"pull_request_targetsupport alongsidepull_requestWhy
The original code tried to resolve
refs/remotes/pull/${GITHUB_REF_NAME}which doesn't exist in the checkout.Additionally,
GITHUB_SHApoints to different commits depending on the event type:Using
GITHUB_HEAD_REF(the PR branch name) allows us to resolve the actual PR head commit viarefs/remotes/origin/${GITHUB_HEAD_REF}, which correctly scans exactly the PR commits for both event types.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.