Add GitHub Actions job summary to SonarCloud workflow#63
Draft
Add GitHub Actions job summary to SonarCloud workflow#63
Conversation
Agent-Logs-Url: https://github.com/304NotModified/SLNX-validator/sessions/5a7193d6-1ad7-45a2-98a1-edf1176dc573 Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add SonarCloud summary step to GitHub Actions
Add GitHub Actions job summary to SonarCloud workflow
Apr 6, 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 runs produced no visible output in the GitHub Actions UI — results were only accessible by navigating to sonarcloud.io directly.
Changes
.github/workflows/sonarcloud.yml: Added aSonarCloud summarystep afterEnd SonarCloud analysisthat writes a markdown summary with a direct link to the SonarCloud dashboard into$GITHUB_STEP_SUMMARYif: always()ensures the summary is written even when earlier steps fail.Original prompt
In the repository 304NotModified/SLNX-validator, add a GitHub Actions Job Summary step to
.github/workflows/sonarcloud.yml.The current last step in the file is "End SonarCloud analysis". Add the following step after it:
This adds a visible summary with a link to the SonarCloud dashboard in the GitHub Actions job summary after every run.
The following is the prior conversation context from the user's chat exploration (may be truncated):
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.Dan check je of de comment
/sonaris, of de commenter schrijfrechten heeft (belangrijk!), en dan draai je de analyse.issue_commentdraait altijd in de context van het base repo → secrets beschikbaar ✅Voordeel: Jij typt
/sonarin de PR, SonarCloud draait.Nadeel: Iets meer configuratie, en je moet de juiste branch/SHA ophalen uit de PR context.
Aanbeveling
Gezien je al een approve & run flow hebt, is de
workflow_runaanpak (twee workflows) eigenlijk het meest naadloos:workflow_run, in base-context met secrets→ Volledig automatisch, geen handmatige stappen, veilig.
Wil je dat ik de twee-workflow aanpak of het
/sonarcommando als PR uitwerk?User: Werk twee-workflow uit in een pr
Assistant: Het lijkt erop dat de agent nog geen taaklink heeft teruggegeven. Laat me even checken of de taak is aangemaakt.
User: @copilot Accepted Confirmation: Confirm agent session
Assistant: Copilot is aan het werk! 🚀