fix: skip GCP-authenticated CI checks for fork PRs#1287
Open
zeroasterisk wants to merge 1 commit intomainfrom
Open
fix: skip GCP-authenticated CI checks for fork PRs#1287zeroasterisk wants to merge 1 commit intomainfrom
zeroasterisk wants to merge 1 commit intomainfrom
Conversation
Fork PRs cannot access OIDC tokens due to GitHub Actions security restrictions. This causes google-github-actions/auth to fail with: 'GitHub Actions did not inject $ACTIONS_ID_TOKEN_REQUEST_TOKEN' Instead of failing with a confusing error, this change: - Detects fork PRs in the discover step - Skips the GCP-authenticated test-agent-template job for forks - Adds a fork-pr-notice job with a clear explanation The Ruff lint/format check (ruff-checks.yml) is unaffected and continues to run on all PRs since it only needs GITHUB_TOKEN.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
There is a problem with the Gemini CLI PR review. Please check the action logs for details. |
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.
Problem
All pull requests from forks currently fail CI with this error:
Root Cause
The
checksworkflow (test_templated_agent.yaml) uses Workload Identity Federation viagoogle-github-actions/auth@v3to authenticate to GCP projectadk-devops. It then pulls a private Docker container from Artifact Registry (europe-west4-docker.pkg.dev/production-ai-template/starter-pack/e2e-tests) to run the lint and test steps.This authentication requires an OIDC identity token (
id-token: writepermission), which GitHub Actions only provides to workflow runs from branches within the same repository. For security reasons, GitHub does not inject OIDC tokens into workflows triggered by fork PRs. This is by design — it prevents fork PRs from accessing repository secrets or impersonating the repo's identity.Impact
Every external contributor's PR fails CI, including:
The failures are not due to code quality issues — the code never gets a chance to be linted or tested. Contributors see a red ❌ with a cryptic GCP auth error, which is confusing and discouraging.
Note: The
ruff-checks.ymlworkflow is not affected — it only usesGITHUB_TOKEN(which works fine on forks) and continues to provide lint feedback on all PRs.What This PR Does
discover-changed-agentsjob by comparinggithub.event.pull_request.head.repo.full_nameagainstgithub.repositorytest-agent-templatejob when the PR comes from a fork (via anifcondition)fork-pr-noticejob that runs instead, printing a clear message explaining why the GCP checks were skippedWhat Contributors See After This Change
Ruff Format & Lint Suggestions✅ runs normally,Fork PR Notice✅ explains the situation, GCP checks are cleanly skipped (no red ❌)Security Consideration
This PR does not expose any secrets or credentials to fork PRs. It simply prevents the workflow from attempting (and failing) to authenticate. The OIDC tokens and GCP credentials remain inaccessible to forks.
A maintainer can always re-run the full CI suite by pushing the fork's changes to a branch within this repository if GCP-authenticated testing is needed before merge.
Alternative Approaches Considered
pull_request_targettrigger — would give forks access to secrets, which is a known security anti-pattern (see GitHub docs)The approach in this PR (skip + notify) is the standard pattern used across Google open-source projects and is the safest option.