Skip to content

Build image on pull_request instead of pull_request_target - #106

Open
gvozdetsky wants to merge 1 commit into
toolforge:mainfrom
gvozdetsky:pull-request-event
Open

gvozdetsky wants to merge 1 commit into
toolforge:mainfrom
gvozdetsky:pull-request-event

Conversation

@gvozdetsky

Copy link
Copy Markdown
Contributor

GitHub blocks pull_request_target on public repositories by default from 2026-12-02 (currently in evaluate mode, see https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target). After that date the image build would stop running for every PR.

  • Trigger on pull_request instead of pull_request_target.
  • Check out the PR head by SHA with actions/checkout instead of git fetch + git checkout ${{ github.head_ref }}. The old step put the branch name, which the PR author chooses, straight into a shell running with QUAY_QUARRY_* and the job token available.
  • Skip pull requests from forks: they get no secrets under pull_request, so the Quay login would fail. To build a fork's image, a maintainer pushes the branch to this repository.

update-container-tags.yaml already runs on pull_request and isn't changed.

Note for admins: Dependabot-triggered pull_request runs only see Dependabot secrets. If Dependabot PRs should build images, add QUAY_QUARRY_USER and QUAY_QUARRY_PASSWORD as Dependabot secrets too.

Same change in the shared workflow: toolforge/github-actions#6.

GitHub blocks pull_request_target on public repositories by default
from 2026-12-02. It also ran 'git checkout ${{ github.head_ref }}' in a
shell with the Quay credentials available, so a branch name could
inject commands.

Check out the PR head by SHA and skip pull requests from forks, which
get no secrets under pull_request.
@gvozdetsky

Copy link
Copy Markdown
Contributor Author

About the red checks: build_and_push (pull_request_target, from main) fails because it runs git checkout pull-request-event against this repository, where the branch only exists in my fork. That happens for every fork PR today. The new pull_request version from this PR shows as skipping, as intended for forks. update-container-tags fails on fork PRs regardless of this change: the read-only token can't push to the fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant