Skip to content

Skip SonarCloud analysis for pull requests from forks - #36

Merged
AkaZver merged 1 commit into
masterfrom
feature/skip-sonar-fork-prs
Aug 20, 2026
Merged

AkaZver merged 1 commit into
masterfrom
feature/skip-sonar-fork-prs

Conversation

@AkaZver

@AkaZver AkaZver commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Problem

Workflows triggered by pull requests from forks do not receive repository secrets (GitHub only passes GITHUB_TOKEN). As a result, secrets.SONAR_TOKEN resolves to an empty string and the sonarqube task fails with:

Not authorized or project not found. Please check the 'SONAR_TOKEN' environment variable...

This happened, for example, in the run for PR #34.

Change

Skip the sonarcloud job for pull requests whose head branch lives in a fork:

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

Resulting behavior

  • PRs from branches of this repository — SonarCloud analysis runs automatically, as before.
  • PRs from forks — the sonarcloud job is skipped, so the workflow finishes green instead of failing. The fork's code gets analyzed right after the merge, when the push to master triggers the analysis.
  • Pushes to master and tags — unchanged; the publish-* jobs still depend on sonarcloud as before.

@AkaZver AkaZver self-assigned this Aug 20, 2026
@AkaZver AkaZver added the bug Something isn't working label Aug 20, 2026
@sonarqubecloud

Copy link
Copy Markdown

@AkaZver
AkaZver merged commit 1d78126 into master Aug 20, 2026
7 checks passed
@AkaZver
AkaZver deleted the feature/skip-sonar-fork-prs branch August 20, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant