Add SonarCloud Job Summary to Actions workflow#62
Merged
304NotModified merged 3 commits intomainfrom Apr 7, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/304NotModified/SLNX-validator/sessions/317ec9e9-0ffd-4326-9b98-20c4631bca49 Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add GitHub Actions job summary to SonarCloud workflow
Add SonarCloud Job Summary to Actions workflow
Apr 6, 2026
304NotModified
requested changes
Apr 7, 2026
Agent-Logs-Url: https://github.com/304NotModified/SLNX-validator/sessions/ec89ba65-bd0b-4668-962b-fd975edbc6a1 Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
304NotModified
approved these changes
Apr 7, 2026
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.
SonarCloud results were not surfaced anywhere in the GitHub Actions UI after a workflow run. This adds a Job Summary step so each run links directly to the SonarCloud results.
Changes
.github/workflows/sonarcloud.yml— appended aSonarCloud summarystep afterEnd SonarCloud analysis:if: always()to ensure the summary is written even if analysis fails/summary/new_code?id=slnx-validator&pullRequest=<number>)/project/overview?id=slnx-validator)Original prompt
Goal
Add a GitHub Actions Job Summary to the SonarCloud workflow so that after each analysis, a summary with a link to the SonarCloud results is shown in the Actions tab.
Change
In
.github/workflows/sonarcloud.yml, add a step after the "End SonarCloud analysis" step that writes a Job Summary to$GITHUB_STEP_SUMMARY:This step should be appended at the end of the steps list in the
sonarcloudjob, after the existing "End SonarCloud analysis" step.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Ik heb dit probleem. Kan ik dit fixen zodat dat sq zomaar code enzo kan pushen? @304NotModified/SLNX-validator/issues/59
Assistant: Het probleem is duidelijk: SonarCloud rapporteert niet op pull requests omdat de workflow onvoldoende permissies heeft. Dit is een bekende beperking van SonarCloud met GitHub Actions.
Oorzaak
SonarCloud heeft de permissie
pull-requests: writenodig om comments te kunnen plaatsen op een PR. Die ontbreekt nu in je workflow. Daarnaast is er nog een tweede probleem: bij PR's van forks heeft SonarCloud geen toegang tot secrets, maar dat speelt hier waarschijnlijk minder.Fix
Voeg
pull-requests: writetoe aan de permissions in jesonarcloud.yml:Wil je dat ik een PR aanmaak om dit te fixen in
304NotModified/SLNX-validator?User: Ja pr
Assistant: We wachten op jouw reactie op het dialoogvenster om verder te gaan met het aanmaken van de PR.
User: @copilot Accepted Confirmation: Confirm agent session
Assistant: Copilot is aan het werk! Je kunt de voortgang hier volgen:
Zodra de PR klaar is, kun je hem reviewen en mergen. 🚀
User: Is dat 2de probleem oplosbaar zonder security issues?
Assistant: Je doelt op het probleem met PRs van forks — daar hebben workflows geen toegang tot secrets (zoals
SONAR_TOKEN), wat een bewuste GitHub-beveiligingsmaatregel is.Het probleem
Bij fork-PR's draait de workflow in de context van de fork, zonder toegang tot secrets van het originele repo. SonarCloud kan dan niet authenticeren en rapporteert dus niet.
Oplossing:
pull_request_targetJe kunt
pull_request_targetgebruiken in plaats vanpull_request. Dit event draait de workflow in de context van het base repo (met toegang tot secrets), ook voor fork-PR's.pull_request_target, kan een aanvaller kwaadaardige code injecteren die jouw secrets steelt.Veilige aanpak: twee-stappen workflow
De aanbevolen veilige aanpak is een gesplitste workflow:
pull_request(geen secrets), voert build & tests uit en slaat het resultaat op als artifact.workflow_run(heeft secrets), pakt het artifact op en stuurt het naar SonarCloud.Dit is precies de aanpak die SonarCloud zelf aanbeveelt. Zie: SonarCloud docs – Automatic analysis with GitHub Actions (forks).
Kort antwoord: Ja, het is oplosbaar zonder security issues, maar het vereist een wat complexere twee-workflow setup. Wil je dat ik daar ook een PR voor maak?
User: Workflow 2 doe ik dan handmatig starten? Kan ik niet een soort commando geven in de pr om sq te draaien? Er is nu ook al een approve workflows run?
Assistant: Goede vraag! Je hebt een paar opties:
Optie 1: Approve & run (wat je nu al hebt)
GitHub heeft ingebouwd dat je voor fork-PR's de workflow handmatig kunt approven. Dit is al veilig — jij keurt de code goed voordat er iets draait. Als je na approve de workflow runt, heeft die wél toegang tot secrets.
Nadeel: Je moet elke keer handmatig approven via de GitHub UI.
Optie 2:
/sonarcommando viaissue_commenttriggerJa, dit kan! Je maakt een workflow die luistert naar een comment op een PR, bijvoorbeeld
/sonar, en dan de analyse draait. Dit heet een slash command of ChatOps patroon.