Skip to content

Commit 900f346

Browse files
authored
Merge pull request #93 from afonsoft/devin/fix-sonar-and-delete-branch
fix: corrige SonarCloud e adiciona delete automático de branch após merge
2 parents 1568fbc + d779679 commit 900f346

6 files changed

Lines changed: 92 additions & 29 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ jobs:
2626
ref: ${{ github.event.pull_request.head.sha }}
2727

2828
- name: 🔍 Qodana Scan
29+
id: qodana
2930
uses: JetBrains/qodana-action@4861e015da555e86a72b862892aba6c2b93e6891
31+
continue-on-error: true
3032
env:
3133
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
3234
with:
@@ -88,21 +90,21 @@ jobs:
8890
8991
- name: 🔍 Prepare analysis on SonarQube
9092
env:
91-
SONAR_TOKEN: ${{ secrets.SONNAR_TOKEN }}
93+
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN || secrets.SONAR_TOKEN }}
9294
run: |
9395
echo "🔍 Checking SonarQube configuration..."
9496
if [ -z "$SONAR_TOKEN" ]; then
95-
echo "❌ SONNAR_TOKEN is not set or empty"
97+
echo "❌ SONAR_TOKEN is not set or empty"
9698
echo "⚠️ Skipping SonarQube analysis"
9799
exit 0
98100
fi
99101
100-
echo "✅ SONNAR_TOKEN is configured"
102+
echo "✅ SONAR_TOKEN is configured"
101103
dotnet sonarscanner begin \
102104
/o:"afonsoft" \
103105
/k:"afonsoft_QRCoder.Core" \
104106
/d:sonar.host.url="https://sonarcloud.io" \
105-
/d:sonar.login="$SONAR_TOKEN" \
107+
/d:sonar.token="$SONAR_TOKEN" \
106108
/d:sonar.scm.provider=git \
107109
/d:sonar.coverage.exclusions="**Test*.cs"
108110
@@ -111,15 +113,15 @@ jobs:
111113

112114
- name: 🔍 Run Code Analysis
113115
env:
114-
SONAR_TOKEN: ${{ secrets.SONNAR_TOKEN }}
116+
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN || secrets.SONAR_TOKEN }}
115117
run: |
116118
echo "🔍 Finalizing SonarQube analysis..."
117119
if [ -z "$SONAR_TOKEN" ]; then
118-
echo "⚠️ SONNAR_TOKEN not configured, skipping analysis"
120+
echo "⚠️ SONAR_TOKEN not configured, skipping analysis"
119121
exit 0
120122
fi
121123
122-
dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN"
124+
dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
123125
124126
# Snyk Security Analysis
125127
snyk:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 🗑️ Delete Branch on Merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
jobs:
9+
delete-merged-branch:
10+
name: 🗑️ Delete merged branch
11+
runs-on: ubuntu-latest
12+
if: |
13+
github.event.pull_request.merged == true &&
14+
github.event.pull_request.head.repo.full_name == github.repository
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- name: 📥 Checkout
20+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
21+
22+
- name: 🗑️ Delete merged branch
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: |
26+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
27+
28+
# Protect default and release branches
29+
case "$BRANCH_NAME" in
30+
main|develop|master|releases/*)
31+
echo "⚠️ Protected branch '$BRANCH_NAME' will not be deleted."
32+
exit 0
33+
;;
34+
esac
35+
36+
echo "🗑️ Deleting merged branch: $BRANCH_NAME"
37+
gh api "repos/${{ github.repository }}/git/refs/heads/${BRANCH_NAME}" --method DELETE \
38+
|| echo "⚠️ Could not delete branch '$BRANCH_NAME' (already removed or from a fork)."
39+
echo "✅ Branch '$BRANCH_NAME' cleanup completed."

.github/workflows/security-scan.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,41 +114,45 @@ jobs:
114114
run: chmod 777 sonar/ -R || true
115115

116116
- name: 🔍 Prepare analysis on SonarQube
117+
env:
118+
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN || secrets.SONAR_TOKEN }}
117119
run: |
118120
echo "🔍 Checking SonarQube configuration..."
119-
if [ -z "${{ secrets.SONNAR_TOKEN }}" ]; then
120-
echo "❌ SONNAR_TOKEN is not set or empty"
121+
if [ -z "$SONAR_TOKEN" ]; then
122+
echo "❌ SONAR_TOKEN is not set or empty"
121123
echo "⚠️ Skipping SonarQube analysis"
122124
exit 0
123125
fi
124126
125-
echo "✅ SONNAR_TOKEN is configured"
127+
echo "✅ SONAR_TOKEN is configured"
126128
dotnet sonarscanner begin \
127129
/o:"afonsoft" \
128130
/k:"afonsoft_QRCoder.Core" \
129131
/d:sonar.host.url="https://sonarcloud.io" \
130-
/d:sonar.login="${{ secrets.SONNAR_TOKEN }}" \
132+
/d:sonar.token="$SONAR_TOKEN" \
131133
/d:sonar.scm.provider=git \
132134
/d:sonar.coverage.exclusions="**Test*.cs"
133135
134136
- name: 🏗️ Build
135137
run: dotnet build QRCoder.Core.sln --configuration release
136138

137139
- name: 🔍 Run Code Analysis
140+
env:
141+
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN || secrets.SONAR_TOKEN }}
138142
run: |
139143
echo "🔍 Finalizing SonarQube analysis..."
140-
if [ -z "${{ secrets.SONNAR_TOKEN }}" ]; then
141-
echo "⚠️ SONNAR_TOKEN not configured, skipping analysis"
144+
if [ -z "$SONAR_TOKEN" ]; then
145+
echo "⚠️ SONAR_TOKEN not configured, skipping analysis"
142146
exit 0
143147
fi
144148
145-
dotnet sonarscanner end /d:sonar.login="${{ secrets.SONNAR_TOKEN }}"
149+
dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
146150
147151
# Security Summary
148152
security-summary:
149153
name: 📋 Security Summary
150154
runs-on: ubuntu-latest
151-
needs: [codeql, snyk]
155+
needs: [codeql, snyk, sonarqube]
152156
if: always()
153157

154158
steps:
@@ -160,17 +164,17 @@ jobs:
160164
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
161165
echo "| 🔍 CodeQL | ${{ needs.codeql.result }} |" >> $GITHUB_STEP_SUMMARY
162166
echo "| 🛡️ Snyk | ${{ needs.snyk.result }} |" >> $GITHUB_STEP_SUMMARY
163-
echo "| 📊 SonarQube | ${{ contains(needs.*.result, 'skipped') && 'skipped' || 'N/A' }} |" >> $GITHUB_STEP_SUMMARY
167+
echo "| 📊 SonarQube | ${{ needs.sonarqube.result }} |" >> $GITHUB_STEP_SUMMARY
164168
echo "" >> $GITHUB_STEP_SUMMARY
165169
166-
if [[ "${{ needs.codeql.result }}" == "failure" || "${{ needs.snyk.result }}" == "failure" ]]; then
170+
if [[ "${{ needs.codeql.result }}" == "failure" || "${{ needs.snyk.result }}" == "failure" || "${{ needs.sonarqube.result }}" == "failure" ]]; then
167171
echo "❌ **Security issues detected! Please review the scan results.**" >> $GITHUB_STEP_SUMMARY
168172
else
169173
echo "✅ **All security scans passed successfully!**" >> $GITHUB_STEP_SUMMARY
170174
fi
171175
172176
- name: 🚨 Security Alert
173-
if: needs.codeql.result == 'failure' || needs.snyk.result == 'failure'
177+
if: needs.codeql.result == 'failure' || needs.snyk.result == 'failure' || needs.sonarqube.result == 'failure'
174178
run: |
175179
echo "🚨 SECURITY ISSUES DETECTED!"
176180
echo "Please review the security scan results immediately."

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# QRCoder.Core - QR Code Generator Library
22

3-
[![Build status](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml)
3+
[![License](https://img.shields.io/github/license/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/blob/main/LICENSE.txt)
4+
[![Build](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml)
5+
[![Code Quality](https://github.com/afonsoft/QRCoder.Core/actions/workflows/code-quality.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/code-quality.yml)
6+
[![Security Scan](https://github.com/afonsoft/QRCoder.Core/actions/workflows/security-scan.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/security-scan.yml)
47
[![codecov](https://codecov.io/gh/afonsoft/QRCoder.Core/graph/badge.svg?token=N8RED1A0D7)](https://codecov.io/gh/afonsoft/QRCoder.Core)
5-
[![NuGet Badge](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/)
6-
[![Code Quality](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=alert_status)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
8+
[![NuGet](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/)
9+
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=alert_status)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
710
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=security_rating)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
11+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=coverage)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
12+
[![GitHub issues](https://img.shields.io/github/issues/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/issues)
13+
![GitHub top language](https://img.shields.io/github/languages/top/afonsoft/QRCoder.Core)
814

915
> **[Leia em Portugues (pt-BR)](README.pt-br.md)**
1016
@@ -337,7 +343,7 @@ reportgenerator \
337343

338344
## Star History
339345

340-
[![Star History Chart](https://api.star-history.com/chart?repos=afonsoft/QRCoder.Core&type=date&legend=top-left&sealed_token=a1KQPztifboHTq3RlLRkwvvPGw3dtFbndqZQpJxDeVkKCiIiJQyi1kuTEocyVlxTQ_wR7U0f6lQ1gBk00x7MNA3wOhureCKWKGRw0nT27SQSXMsSECsH8w)](https://www.star-history.com/?repos=afonsoft%2FQRCoder.Core&type=date&legend=top-left)
346+
[![Star History Chart](https://api.star-history.com/svg?repos=afonsoft/qrcoder.core&type=Date)](https://star-history.com/#afonsoft/qrcoder.core&Date)
341347

342348
## StarMapper
343349

README.pt-br.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# QRCoder.Core - Biblioteca Geradora de QR Code
22

3-
[![Build status](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml)
3+
[![Licenca](https://img.shields.io/github/license/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/blob/main/LICENSE.txt)
4+
[![Build](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml)
5+
[![Code Quality](https://github.com/afonsoft/QRCoder.Core/actions/workflows/code-quality.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/code-quality.yml)
6+
[![Security Scan](https://github.com/afonsoft/QRCoder.Core/actions/workflows/security-scan.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/security-scan.yml)
47
[![codecov](https://codecov.io/gh/afonsoft/QRCoder.Core/graph/badge.svg?token=N8RED1A0D7)](https://codecov.io/gh/afonsoft/QRCoder.Core)
5-
[![NuGet Badge](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/)
6-
[![Code Quality](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=alert_status)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
8+
[![NuGet](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/)
9+
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=alert_status)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
710
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=security_rating)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
11+
[![Cobertura](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=coverage)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
12+
[![GitHub issues](https://img.shields.io/github/issues/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/issues)
13+
![GitHub top language](https://img.shields.io/github/languages/top/afonsoft/QRCoder.Core)
814

915
> **[Read in English (en-US)](README.md)**
1016
@@ -361,7 +367,7 @@ reportgenerator \
361367

362368
## Historico de Estrelas
363369

364-
[![Star History Chart](https://api.star-history.com/chart?repos=afonsoft/QRCoder.Core&type=date&legend=top-left&sealed_token=a1KQPztifboHTq3RlLRkwvvPGw3dtFbndqZQpJxDeVkKCiIiJQyi1kuTEocyVlxTQ_wR7U0f6lQ1gBk00x7MNA3wOhureCKWKGRw0nT27SQSXMsSECsH8w)](https://www.star-history.com/?repos=afonsoft%2FQRCoder.Core&type=date&legend=top-left)
370+
[![Star History Chart](https://api.star-history.com/svg?repos=afonsoft/qrcoder.core&type=Date)](https://star-history.com/#afonsoft/qrcoder.core&Date)
365371

366372
## StarMapper
367373

readme.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11

22
# QRCoder.Core - QR Code Generator Library
33

4-
[![Build status](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml)
4+
[![License](https://img.shields.io/github/license/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/blob/main/LICENSE.txt)
5+
[![Build](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/ci-build-test.yml)
6+
[![Code Quality](https://github.com/afonsoft/QRCoder.Core/actions/workflows/code-quality.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/code-quality.yml)
7+
[![Security Scan](https://github.com/afonsoft/QRCoder.Core/actions/workflows/security-scan.yml/badge.svg?branch=main)](https://github.com/afonsoft/QRCoder.Core/actions/workflows/security-scan.yml)
58
[![codecov](https://codecov.io/gh/afonsoft/QRCoder.Core/graph/badge.svg?token=N8RED1A0D7)](https://codecov.io/gh/afonsoft/QRCoder.Core)
6-
[![NuGet Badge](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/)
7-
[![Code Quality](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=alert_status)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
9+
[![NuGet](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/)
10+
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=alert_status)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
811
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=security_rating)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
12+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=coverage)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core)
13+
[![GitHub issues](https://img.shields.io/github/issues/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/issues)
14+
![GitHub top language](https://img.shields.io/github/languages/top/afonsoft/QRCoder.Core)
915

1016
## Project Description / Descrição do Projeto
1117

0 commit comments

Comments
 (0)