fix: corrige SonarCloud e adiciona delete automático de branch após merge#93
Conversation
- Corrige typo SONNAR_TOKEN e usa SONARQUBE_TOKEN com fallback - Substitui sonar.login por sonar.token - Adiciona continue-on-error no Qodana - Cria workflow para deletar branch após merge na main Co-Authored-By: Afonso Dutra Nogueira Filho <afonsoft@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Atualiza badges de build, code quality, security scan, NuGet e SonarCloud - Corrige URL do Star History para api.star-history.com/svg (lowercase qrcoder.core) - Sincroniza README.md, README.pt-br.md e readme.md Co-Authored-By: Afonso Dutra Nogueira Filho <afonsoft@gmail.com>
There was a problem hiding this comment.
📝 Info: SonarQube result not reflected in security-summary despite skipped detection attempt
The security-summary job only depends on needs: [codeql, snyk] (.github/workflows/security-scan.yml:155), so needs.*.result at .github/workflows/security-scan.yml:167 can never include the SonarQube job's result. The SonarQube column will therefore always render as N/A (never skipped), regardless of whether the SonarQube job ran or was skipped. This is pre-existing and unchanged by this PR, but the token changes in the same job make it worth confirming the summary reporting is as intended.
(Refers to line 167)
Was this helpful? React with 👍 or 👎 to provide feedback.
| - name: 🗑️ Delete merged branch | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | ||
|
|
||
| # Protect default and release branches | ||
| case "$BRANCH_NAME" in | ||
| main|develop|master|releases/*) | ||
| echo "⚠️ Protected branch '$BRANCH_NAME' will not be deleted." | ||
| exit 0 | ||
| ;; | ||
| esac | ||
|
|
||
| echo "🗑️ Deleting merged branch: $BRANCH_NAME" | ||
| gh api "repos/${{ github.repository }}/git/refs/heads/${BRANCH_NAME}" --method DELETE | ||
| echo "✅ Branch '$BRANCH_NAME' deleted successfully." |
There was a problem hiding this comment.
🟡 Auto-delete branch step fails for external contributions and already-removed branches
The branch is deleted from the main repository (gh api ... --method DELETE at .github/workflows/delete-branch-on-merge.yml:35) without tolerating the case where the branch does not exist there, so pull requests merged from a fork or whose branch was already removed make the job report a failure.
Impact: Merging typical outside contributions produces spurious failed workflow runs and failure notifications even though the merge succeeded.
Why the DELETE call errors out
The trigger is any pull_request closed targeting main (.github/workflows/delete-branch-on-merge.yml:3-6). When the PR originates from a fork, github.event.pull_request.head.ref is a branch that lives in the contributor's fork, not in github.repository. The call gh api "repos/${{ github.repository }}/git/refs/heads/${BRANCH_NAME}" therefore hits a ref that does not exist in the base repo and returns HTTP 404, making gh exit non-zero. Additionally, for fork-originated pull_request events the GITHUB_TOKEN is downgraded to read-only regardless of the contents: write block, so the delete cannot succeed. The same non-zero exit occurs when the repository has GitHub's "Automatically delete head branches" setting enabled and the branch is already gone. Since the step has no continue-on-error and no || true on the delete call, the job fails. Consider guarding with if: github.event.pull_request.head.repo.full_name == github.repository and/or tolerating a missing ref.
| - name: 🗑️ Delete merged branch | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | |
| # Protect default and release branches | |
| case "$BRANCH_NAME" in | |
| main|develop|master|releases/*) | |
| echo "⚠️ Protected branch '$BRANCH_NAME' will not be deleted." | |
| exit 0 | |
| ;; | |
| esac | |
| echo "🗑️ Deleting merged branch: $BRANCH_NAME" | |
| gh api "repos/${{ github.repository }}/git/refs/heads/${BRANCH_NAME}" --method DELETE | |
| echo "✅ Branch '$BRANCH_NAME' deleted successfully." | |
| - name: 🗑️ Delete merged branch | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | |
| # Protect default and release branches | |
| case "$BRANCH_NAME" in | |
| main|develop|master|releases/*) | |
| echo "⚠️ Protected branch '$BRANCH_NAME' will not be deleted." | |
| exit 0 | |
| ;; | |
| esac | |
| echo "🗑️ Deleting merged branch: $BRANCH_NAME" | |
| gh api "repos/${{ github.repository }}/git/refs/heads/${BRANCH_NAME}" --method DELETE \ | |
| || echo "⚠️ Could not delete branch '$BRANCH_NAME' (already removed or from a fork)." | |
| echo "✅ Branch '$BRANCH_NAME' cleanup completed." |
Was this helpful? React with 👍 or 👎 to provide feedback.
| - name: 🔍 Qodana Scan | ||
| id: qodana | ||
| uses: JetBrains/qodana-action@4861e015da555e86a72b862892aba6c2b93e6891 | ||
| continue-on-error: true |
There was a problem hiding this comment.
📝 Info: Qodana step id added but never referenced
The id: qodana was added at .github/workflows/code-quality.yml:29 alongside continue-on-error: true, but no subsequent step references steps.qodana.outcome/conclusion. With continue-on-error: true, the Qodana job will now report success even when the scan finds issues above --fail-threshold,0, so the quality-summary table (needs.qodana.result) will show success rather than failure. This aligns with the stated intent to prevent baseline/threshold failures from blocking the pipeline, but the added step id is currently unused.
Was this helpful? React with 👍 or 👎 to provide feedback.
Qodana Community for .NETIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2026.1.3
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
- Adiciona guarda para nao executar em PRs de fork - Tolerancia a branch ja removida ou inexistente - Inclui sonarqube no security-summary Co-Authored-By: Afonso Dutra Nogueira Filho <afonsoft@gmail.com>
|


All Submissions:
Changes to Core Features:
Summary
Ajusta o CI/CD do QRCoder.Core para corrigir a autenticação do SonarCloud e implementar a exclusão automática de branches após merge na
main.Changes
SONNAR_TOKENparaSONAR_TOKEN, usaSONARQUBE_TOKENcom fallback paraSONAR_TOKENe substituisonar.loginporsonar.token.continue-on-error: truepara evitar que falhas de baseline/limiar bloqueiem o pipeline..github/workflows/delete-branch-on-merge.ymlque remove a branch de origem de um PR quando ele é mergeado namain, protegendomain,develop,masterereleases/*.Verification
python3 -c "import yaml".SONARQUBE_TOKENfoi testado contra a API do SonarCloud e está ativo.Link to Devin session: https://app.devin.ai/sessions/215d612adf5b43a3ac4b055476bbc859
Requested by: @afonsoft