fix(ci): check out PR head in shared maven build under pull_request_target#46
Merged
Conversation
…arget The shared workflow's checkout step had no explicit ref, so under pull_request_target it resolved to the base branch's tip. That meant every Dependabot PR's CI was building the base branch instead of the proposed changes — the green checkmark only proved that base still built, not that the bump was viable. Pin ref to github.event.pull_request.head.sha when present, falling back to github.sha so push and workflow_dispatch triggers keep their existing behavior. The dependabot-pr.yml gates already restrict execution to PRs opened by dependabot[bot], so checking out the PR head under pull_request_target is acceptable here: Dependabot is first-party and only mutates manifest/lockfile content.
b4e872b to
2ef36c4
Compare
tgmuender
approved these changes
Jun 22, 2026
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.
Why
shared-maven-build.yml's checkout step has no explicitref, so underpull_request_targetit resolves to the base branch's tip. Every Dependabot PR's CI has therefore been building the base branch, not the proposed changes — the green checkmark only confirmed that master still builds, not that the bump was viable.The bug stayed invisible for most bumps (a
pom.xmlversion diff alone resolves fine against the base tree), but it surfaced now forcode-style-settings: that artifact ships generated files (hooks/pre-push,portal-java-formatter.xml, …) which the build unpacks over the tree, and any unsynced commit at base trips the post-buildensure-no-uncommitted-codecheck.Change
Pin
refto the PR head when available, falling back togithub.sha:pull_request_target→ PR head (the fix)push/workflow_dispatch/schedule→github.sha, identical to todayOnly
pull_request_targetcallers (the 20 repos'dependabot-pr.yml) see new behavior. Acceptable here because the trigger is already gated togithub.event.pull_request.user.login == 'dependabot[bot]', and Dependabot is first-party.