<#7320 ci(flyte-binary-v2): use pull_request_targe...
# flyte-github
a
#7320 ci(flyte-binary-v2): use pull_request_target so fork PRs can access DEPOT_PROJECT_ID Pull request opened by pingsutw Why The
Build & Push Flyte Single Binary Images v2
workflow validates and uses
vars.DEPOT_PROJECT_ID
to drive Depot builds. GitHub does not pass repository variables (or secrets) to workflows triggered by
pull_request
events from forks. As a result, every PR opened from a fork (e.g.
pingsutw/flyte
) failed the
Validate Depot project id
step with:
Copy code
##[error]DEPOT_PROJECT_ID repo variable is not set.
Branches in
flyteorg/flyte
worked fine; only fork PRs failed. We want fork PRs to run the same build verification as in-repo branches. What changed •
pull_request
→
pull_request_target
for this workflow.
pull_request_target
runs in the base repo context, so
vars.DEPOT_PROJECT_ID
(and any non-secret config) is available even for fork PRs. • All
actions/checkout@v4
steps now explicitly check out
github.event.pull_request.head.sha || github.sha
. By default
pull_request_target
checks out the base ref, which would test the wrong code; this makes the workflow actually build the PR's contents. •
PUSH_IMAGES
tightened: now requires
pull_request_target
and
head.repo.full_name == github.repository
and the
test-push-image
label. Fork PRs can never trigger an image push, so
secrets.FLYTE_BOT_PAT
is never reachable from fork-controlled code. • Added a SECURITY comment at the top of
on:
documenting the tradeoff. Security considerations
pull_request_target
+ checking out the PR head means fork-authored code (Dockerfile, Makefile, build scripts) executes with access to whatever the base-repo job exposes. Mitigations applied: • No repo secrets are referenced in any step that runs for fork PRs. • Image push / GHCR login are gated to base-repo branches only. • The only base-repo value exposed to fork code is
vars.DEPOT_PROJECT_ID
, which is a public Depot project identifier (not a credential). Auth to Depot uses OIDC with
id-token: write
— a malicious fork could consume Depot build minutes on this project, but cannot exfiltrate credentials. If consuming Depot minutes from fork PRs is unacceptable, an alternative is to skip the depot job entirely on fork PRs (
if: github.event.pull_request.head.repo.full_name == github.repository
) instead of switching to
pull_request_target
. Test plan • CI on this PR (
test-2
, in-repo branch) still passes with
DEPOT_PROJECT_ID
populated. • After merge, open a fork PR and confirm
Validate Depot project id
passes and the Depot build runs. • Confirm
PUSH_IMAGES
evaluates to
false
on fork PRs (no GHCR login attempt). • Confirm push-to-main still pushes images as before. flyteorg/flyte