fix(ci): split TruffleHog scan by event type#49
Merged
Conversation
The original step passed `base: main` and `head: HEAD` unconditionally.
On a push to main, the GitHub event resolves both to the same commit
SHA, and the trufflehog-action exits 1 by design ("BASE and HEAD
commits are the same. TruffleHog won't scan anything").
Fix: split into two conditional steps.
- On `pull_request` events: scan the diff between PR base SHA and PR
head SHA. Fast, focused, catches secrets introduced in the PR.
- On `push` to main and on the weekly `schedule`: scan the entire
filesystem via `path: ./`. Slower but comprehensive; catches
anything that slipped past the PR diff (rebases, force-pushes, or
the action's own future regressions).
Gitleaks unchanged; it does not have the BASE==HEAD failure mode.
Co-Authored-By: Vesper (Claude Opus 4.7) <noreply@anthropic.com>
Provenance: agent-authored, human-reviewed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hotfix for the secrets-scan workflow shipped in PR #48. TruffleHog went red on the post-merge push to main with `BASE and HEAD commits are the same. TruffleHog won't scan anything` (the action exits 1 by design when this happens).
Root cause
The original step passed `base: ${{ github.event.repository.default_branch }}` (which renders to the literal string `main`) and `head: HEAD` unconditionally. On a push event to main, both resolve to the same commit SHA. PR runs worked because PR events resolve `main` to the merge-base of the target branch, which differs from the PR HEAD.
Fix
Split the TruffleHog step into two event-conditional steps:
Gitleaks is unchanged — it does not have the BASE==HEAD failure mode and runs the same way for both events.
Test plan
Notes
This is the kind of CI configuration that is easier to verify by merging and watching than by speculation. If something else breaks, the iteration cost is one commit.
🤖 Generated with Claude Code
Provenance: agent-authored, human-reviewed