diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 7f2f645..9f8ec7c 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -26,7 +26,9 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: πŸ” Qodana Scan + id: qodana uses: JetBrains/qodana-action@4861e015da555e86a72b862892aba6c2b93e6891 + continue-on-error: true env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} with: @@ -88,21 +90,21 @@ jobs: - name: πŸ” Prepare analysis on SonarQube env: - SONAR_TOKEN: ${{ secrets.SONNAR_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN || secrets.SONAR_TOKEN }} run: | echo "πŸ” Checking SonarQube configuration..." if [ -z "$SONAR_TOKEN" ]; then - echo "❌ SONNAR_TOKEN is not set or empty" + echo "❌ SONAR_TOKEN is not set or empty" echo "⚠️ Skipping SonarQube analysis" exit 0 fi - echo "βœ… SONNAR_TOKEN is configured" + echo "βœ… SONAR_TOKEN is configured" dotnet sonarscanner begin \ /o:"afonsoft" \ /k:"afonsoft_QRCoder.Core" \ /d:sonar.host.url="https://sonarcloud.io" \ - /d:sonar.login="$SONAR_TOKEN" \ + /d:sonar.token="$SONAR_TOKEN" \ /d:sonar.scm.provider=git \ /d:sonar.coverage.exclusions="**Test*.cs" @@ -111,15 +113,15 @@ jobs: - name: πŸ” Run Code Analysis env: - SONAR_TOKEN: ${{ secrets.SONNAR_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN || secrets.SONAR_TOKEN }} run: | echo "πŸ” Finalizing SonarQube analysis..." if [ -z "$SONAR_TOKEN" ]; then - echo "⚠️ SONNAR_TOKEN not configured, skipping analysis" + echo "⚠️ SONAR_TOKEN not configured, skipping analysis" exit 0 fi - dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN" + dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN" # Snyk Security Analysis snyk: diff --git a/.github/workflows/delete-branch-on-merge.yml b/.github/workflows/delete-branch-on-merge.yml new file mode 100644 index 0000000..0a773be --- /dev/null +++ b/.github/workflows/delete-branch-on-merge.yml @@ -0,0 +1,39 @@ +name: πŸ—‘οΈ Delete Branch on Merge + +on: + pull_request: + types: [closed] + branches: [main] + +jobs: + delete-merged-branch: + name: πŸ—‘οΈ Delete merged branch + runs-on: ubuntu-latest + if: | + github.event.pull_request.merged == true && + github.event.pull_request.head.repo.full_name == github.repository + permissions: + contents: write + + steps: + - name: πŸ“₯ Checkout + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 + + - 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 "⚠️ Could not delete branch '$BRANCH_NAME' (already removed or from a fork)." + echo "βœ… Branch '$BRANCH_NAME' cleanup completed." diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml index f18369e..8a2fc09 100644 --- a/.github/workflows/security-scan.yml +++ b/.github/workflows/security-scan.yml @@ -114,20 +114,22 @@ jobs: run: chmod 777 sonar/ -R || true - name: πŸ” Prepare analysis on SonarQube + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN || secrets.SONAR_TOKEN }} run: | echo "πŸ” Checking SonarQube configuration..." - if [ -z "${{ secrets.SONNAR_TOKEN }}" ]; then - echo "❌ SONNAR_TOKEN is not set or empty" + if [ -z "$SONAR_TOKEN" ]; then + echo "❌ SONAR_TOKEN is not set or empty" echo "⚠️ Skipping SonarQube analysis" exit 0 fi - echo "βœ… SONNAR_TOKEN is configured" + echo "βœ… SONAR_TOKEN is configured" dotnet sonarscanner begin \ /o:"afonsoft" \ /k:"afonsoft_QRCoder.Core" \ /d:sonar.host.url="https://sonarcloud.io" \ - /d:sonar.login="${{ secrets.SONNAR_TOKEN }}" \ + /d:sonar.token="$SONAR_TOKEN" \ /d:sonar.scm.provider=git \ /d:sonar.coverage.exclusions="**Test*.cs" @@ -135,20 +137,22 @@ jobs: run: dotnet build QRCoder.Core.sln --configuration release - name: πŸ” Run Code Analysis + env: + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN || secrets.SONAR_TOKEN }} run: | echo "πŸ” Finalizing SonarQube analysis..." - if [ -z "${{ secrets.SONNAR_TOKEN }}" ]; then - echo "⚠️ SONNAR_TOKEN not configured, skipping analysis" + if [ -z "$SONAR_TOKEN" ]; then + echo "⚠️ SONAR_TOKEN not configured, skipping analysis" exit 0 fi - dotnet sonarscanner end /d:sonar.login="${{ secrets.SONNAR_TOKEN }}" + dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN" # Security Summary security-summary: name: πŸ“‹ Security Summary runs-on: ubuntu-latest - needs: [codeql, snyk] + needs: [codeql, snyk, sonarqube] if: always() steps: @@ -160,17 +164,17 @@ jobs: echo "|------|--------|" >> $GITHUB_STEP_SUMMARY echo "| πŸ” CodeQL | ${{ needs.codeql.result }} |" >> $GITHUB_STEP_SUMMARY echo "| πŸ›‘οΈ Snyk | ${{ needs.snyk.result }} |" >> $GITHUB_STEP_SUMMARY - echo "| πŸ“Š SonarQube | ${{ contains(needs.*.result, 'skipped') && 'skipped' || 'N/A' }} |" >> $GITHUB_STEP_SUMMARY + echo "| πŸ“Š SonarQube | ${{ needs.sonarqube.result }} |" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - if [[ "${{ needs.codeql.result }}" == "failure" || "${{ needs.snyk.result }}" == "failure" ]]; then + if [[ "${{ needs.codeql.result }}" == "failure" || "${{ needs.snyk.result }}" == "failure" || "${{ needs.sonarqube.result }}" == "failure" ]]; then echo "❌ **Security issues detected! Please review the scan results.**" >> $GITHUB_STEP_SUMMARY else echo "βœ… **All security scans passed successfully!**" >> $GITHUB_STEP_SUMMARY fi - name: 🚨 Security Alert - if: needs.codeql.result == 'failure' || needs.snyk.result == 'failure' + if: needs.codeql.result == 'failure' || needs.snyk.result == 'failure' || needs.sonarqube.result == 'failure' run: | echo "🚨 SECURITY ISSUES DETECTED!" echo "Please review the security scan results immediately." diff --git a/README.md b/README.md index cca02b7..026f064 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,16 @@ # QRCoder.Core - QR Code Generator Library -[![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) +[![License](https://img.shields.io/github/license/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/blob/main/LICENSE.txt) +[![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) +[![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) +[![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) [![codecov](https://codecov.io/gh/afonsoft/QRCoder.Core/graph/badge.svg?token=N8RED1A0D7)](https://codecov.io/gh/afonsoft/QRCoder.Core) -[![NuGet Badge](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/) -[![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) +[![NuGet](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/) +[![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) [![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) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=coverage)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core) +[![GitHub issues](https://img.shields.io/github/issues/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/issues) +![GitHub top language](https://img.shields.io/github/languages/top/afonsoft/QRCoder.Core) > **[Leia em Portugues (pt-BR)](README.pt-br.md)** @@ -337,7 +343,7 @@ reportgenerator \ ## Star History -[![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) +[![Star History Chart](https://api.star-history.com/svg?repos=afonsoft/qrcoder.core&type=Date)](https://star-history.com/#afonsoft/qrcoder.core&Date) ## StarMapper diff --git a/README.pt-br.md b/README.pt-br.md index afca615..f86a684 100644 --- a/README.pt-br.md +++ b/README.pt-br.md @@ -1,10 +1,16 @@ # QRCoder.Core - Biblioteca Geradora de QR Code -[![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) +[![Licenca](https://img.shields.io/github/license/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/blob/main/LICENSE.txt) +[![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) +[![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) +[![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) [![codecov](https://codecov.io/gh/afonsoft/QRCoder.Core/graph/badge.svg?token=N8RED1A0D7)](https://codecov.io/gh/afonsoft/QRCoder.Core) -[![NuGet Badge](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/) -[![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) +[![NuGet](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/) +[![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) [![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) +[![Cobertura](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=coverage)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core) +[![GitHub issues](https://img.shields.io/github/issues/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/issues) +![GitHub top language](https://img.shields.io/github/languages/top/afonsoft/QRCoder.Core) > **[Read in English (en-US)](README.md)** @@ -361,7 +367,7 @@ reportgenerator \ ## Historico de Estrelas -[![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) +[![Star History Chart](https://api.star-history.com/svg?repos=afonsoft/qrcoder.core&type=Date)](https://star-history.com/#afonsoft/qrcoder.core&Date) ## StarMapper diff --git a/readme.md b/readme.md index 546a337..d1e191f 100644 --- a/readme.md +++ b/readme.md @@ -1,11 +1,17 @@ # QRCoder.Core - QR Code Generator Library -[![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) +[![License](https://img.shields.io/github/license/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/blob/main/LICENSE.txt) +[![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) +[![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) +[![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) [![codecov](https://codecov.io/gh/afonsoft/QRCoder.Core/graph/badge.svg?token=N8RED1A0D7)](https://codecov.io/gh/afonsoft/QRCoder.Core) -[![NuGet Badge](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/) -[![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) +[![NuGet](https://img.shields.io/nuget/v/QRCoder.Core.svg)](https://www.nuget.org/packages/QRCoder.Core/) +[![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) [![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) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=afonsoft_QRCoder.Core&metric=coverage)](https://sonarcloud.io/project/overview?id=afonsoft_QRCoder.Core) +[![GitHub issues](https://img.shields.io/github/issues/afonsoft/QRCoder.Core)](https://github.com/afonsoft/QRCoder.Core/issues) +![GitHub top language](https://img.shields.io/github/languages/top/afonsoft/QRCoder.Core) ## Project Description / DescriΓ§Γ£o do Projeto