Skip to content

fix: skip secret-dependent CI steps for fork PRs#1411

Open
IgnacioN99 wants to merge 1 commit into
mainfrom
fix-ci-for-fork-prs
Open

fix: skip secret-dependent CI steps for fork PRs#1411
IgnacioN99 wants to merge 1 commit into
mainfrom
fix-ci-for-fork-prs

Conversation

@IgnacioN99

Copy link
Copy Markdown
Contributor

Problem

CI fails on PRs coming from forks. GitHub does not expose repository secrets to fork PRs for security reasons, so any step depending on secrets fails.

Validated by opening a test fork PR (#1410) — Merge Results job failed immediately at SonarQube Scanner because SONAR_TOKEN and SONAR_HOST_URL were empty.

Related task: https://app.notion.com/p/e4411b2f2b8b4a0e87f1f9a1d5cf315a

Root cause

Two steps in merge_results job are incompatible with fork PRs:

  • SonarQube Scanner — requires SONAR_TOKEN + SONAR_HOST_URL (unavailable in forks)
  • Commit & push API Docs — requires write access via PUSH_KEY (unavailable in forks)

Fix

Add an if condition to both steps to skip them when the PR originates from a fork:

github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

This keeps full CI behavior for PRs from within the repo while gracefully skipping secret-dependent steps for external contributors.

Test plan

  • Open a fork PR and verify Merge Results passes (SonarQube skipped)
  • Open an internal PR and verify SonarQube still runs normally

SonarQube Scanner fails on fork PRs because SONAR_TOKEN and
SONAR_HOST_URL secrets are not available in that context. The
`Commit & push API Docs` step would similarly fail since the
GITHUB_TOKEN has read-only permissions for forks.

Add `if` conditions to skip both steps when the PR originates
from a fork.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant