Skip to content

chore: #2080 Skip sonar-cloud-analysis job on pull requests from forks - #2081

Merged
lbroudoux merged 1 commit into
microcks:masterfrom
Heyy-Himanshuu:chore/2080-skip-sonar-on-fork-prs
May 4, 2026
Merged

lbroudoux merged 1 commit into
microcks:masterfrom
Heyy-Himanshuu:chore/2080-skip-sonar-on-fork-prs

Conversation

@Heyy-Himanshuu

@Heyy-Himanshuu Heyy-Himanshuu commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

fixes #2080.

The existing if: github.repository_owner == "microcks" guard on the sonar-cloud-analysis workflow does not actually exclude fork PRs github.repository_owner resolves to the owner of the base repository (always microcks), not the head of the PR. As a result, every fork PR triggers the job and fails because GitHub Actions doesn't pass repository secrets to PRs from forks, so SONAR_TOKEN ends up empty and the scanner reports "Project not found."

This PR augments the guard so that, for pull_request events, the PR head repo must match the base repo. push and schedule events keep running unconditionally because they always have access to secrets.

Behaviour after the fix

Trigger Today After
push to master runs runs
schedule (cron) runs runs
pull_request from same-repo branch (maintainer) runs runs
pull_request from fork runs and fails skipped cleanly

Skipped jobs surface as a neutral status in the PR check list, so contributors and reviewers don't have to dig through logs to confirm the failure was the SonarCloud-on-fork-PR limitation rather than the contribution itself.

Test plan

  • On merge: a same-repo PR (or push to master) still triggers sonar-cloud-analysis / Build and analyze.
  • After merge, the next fork PR opened against this repo shows sonar-cloud-analysis / Build and analyze as skipped, not failing.

Related issue(s)

Resolves #2080

…rom forks

The existing 'if: github.repository_owner == \"microcks\"' guard does
not actually exclude fork PRs - github.repository_owner resolves to
the owner of the base repository (always 'microcks'), not the head
of the PR. As a result, every fork PR triggers the job, which then
fails because GitHub Actions does not pass repository secrets to PRs
from forks and SONAR_TOKEN ends up empty, producing the "Project not
found" error visible on every fork PR opened against microcks#2058.

Augment the guard so that, for pull_request events, the head repo
must match the base repo. push and schedule events keep running
unconditionally because they always have access to secrets.

Behaviour matrix after the fix:

- push to master: runs (unchanged).
- schedule cron: runs (unchanged).
- pull_request from a same-repo branch (maintainer): runs (unchanged).
- pull_request from a fork: cleanly skipped instead of failing.

Skipped jobs surface as a neutral status in the PR check list, so
contributors and reviewers no longer have to dig through logs to
confirm the failure is the SonarCloud-on-fork-PR limitation rather
than the contribution itself.

Resolves microcks#2080

Signed-off-by: Git-HimanshuRathi <[email protected]>

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Thanks!

@lbroudoux lbroudoux added kind/bug component/build github_actions Pull requests that update GitHub Actions code labels May 4, 2026
@lbroudoux lbroudoux added this to the 1.15.0 milestone May 4, 2026
@lbroudoux
lbroudoux merged commit bc9ea5d into microcks:master May 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/build github_actions Pull requests that update GitHub Actions code kind/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: skip sonar-cloud-analysis job on pull requests from forks

2 participants