Skip to content

Fix TruffleHog secret scan failing when BASE and HEAD are identical#454

Merged
jamespepper81 merged 2 commits into
devfrom
copilot/fix-secrets-scan-error
Jan 11, 2026
Merged

Fix TruffleHog secret scan failing when BASE and HEAD are identical#454
jamespepper81 merged 2 commits into
devfrom
copilot/fix-secrets-scan-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 11, 2026

TruffleHog fails with "BASE and HEAD commits are the same" because the workflow used github.event.repository.default_branch (a branch name) as the base commit SHA, causing it to resolve to the same commit as HEAD in push and scheduled events.

Changes

Split the secret scan into three conditional steps using correct context variables per event type:

  • Pull requests: github.event.pull_request.base.shagithub.event.pull_request.head.sha
  • Push events: github.event.beforegithub.sha
  • Scheduled runs: Full scan with no base/head (scans entire repository)
- name: 🔍 TruffleHog Secret Scan (PR)
  if: github.event_name == 'pull_request'
  uses: trufflesecurity/trufflehog@main
  with:
    base: ${{ github.event.pull_request.base.sha }}
    head: ${{ github.event.pull_request.head.sha }}
Original prompt

what is this on a secrets scan?

Error: BASE and HEAD commits are the same. TruffleHog won't scan anything. Please see documentation (https://github.com/trufflesecurity/trufflehog#octocat-trufflehog-github-action).
Error: Process completed with exit code 1.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error in secrets scan with TruffleHog Fix TruffleHog secret scan failing when BASE and HEAD are identical Jan 11, 2026
Copilot AI requested a review from jamespepper81 January 11, 2026 20:17
@jamespepper81 jamespepper81 marked this pull request as ready for review January 11, 2026 20:18
@jamespepper81 jamespepper81 merged commit d1ed63e into dev Jan 11, 2026
3 checks passed
@jamespepper81 jamespepper81 deleted the copilot/fix-secrets-scan-error branch January 11, 2026 20:19
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.

2 participants