Skip to content

Run image workflows on pull_request instead of pull_request_target - #538

Open
gvozdetsky wants to merge 2 commits into
toolforge:mainfrom
gvozdetsky:pull-request-event
Open

gvozdetsky wants to merge 2 commits into
toolforge:mainfrom
gvozdetsky:pull-request-event

Conversation

@gvozdetsky

@gvozdetsky gvozdetsky commented Oct 26, 2026 •

Copy link
Copy Markdown

GitHub blocks pull_request_target on public repositories by default from 2026-12-02. It already warns on every image build, e.g. https://github.com/toolforge/paws/actions/runs/40342868756 (Workflow execution policy warning (evaluate mode); see https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target). After that date no PR would build pr-N images or update paws/values.yaml.

Depends on toolforge/github-actions#6 and on the build-and-push-v5 tag created after it's merged. Don't merge this before the tag exists.

  • The seven image workflows trigger on pull_request and use build-and-push-v5. That version checks out the PR head by SHA instead of running git checkout ${{ github.head_ref }} in a shell, and skips fork PRs.
  • update-container-tags.yaml: triggers on pull_request, skips fork PRs, and checks out the head branch through actions/checkout instead of git checkout ${{ github.head_ref }} in a shell. That step ran with PERSONAL_ACCESS_TOKEN stored in .git/config, and the workflow has no paths filter, so any PR could reach it.
  • notification.yaml: drop the unused inital_commit line, which also put ${{ github.head_ref }} into a shell.

What changes for contributors:

  • PRs from forks (14 of the last 200) no longer build images or update tags. Under pull_request they get no secrets. A maintainer pushes such a branch to this repository to get them.
  • Dependabot-triggered pull_request runs only see Dependabot secrets. For Dependabot PRs that touch images/ (like Bump idna from 3.7 to 3.15 in /images/minesweeper #516), an admin needs to add QUAY_USER, QUAY_PASSWORD and PERSONAL_ACCESS_TOKEN as Dependabot secrets.

Same change in toolforge/quarry: toolforge/quarry#106.

Eugene Gvozdetsky added 2 commits October 26, 2026 16:11
GitHub blocks pull_request_target on public repositories by default
from 2026-12-02. These workflows also ran 'git checkout
${{ github.head_ref }}' in a shell with the Quay credentials or
PERSONAL_ACCESS_TOKEN available, so a branch name could inject commands.

Use build-and-push-v5 of toolforge/github-actions, which checks out the
PR head by SHA and skips pull requests from forks; do the same in
update-container-tags. Fork PRs no longer build images: push the branch
to this repository instead.
It was never read, and it put ${{ github.head_ref }}, a branch name the
PR author chooses, into a shell.
@gvozdetsky

Copy link
Copy Markdown
Author

The failing update-container-tags check comes from the pull_request_target version on main: actions/checkout now refuses to check out fork code from pull_request_target ("Refusing to check out fork pull request code…"). With this PR merged, that job is skipped for fork PRs. The image workflows did not run because this PR doesn't touch images/.

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