Files
wp-plugin-starter-template-…/.github/workflows/sonarcloud.yml
marcusquinn cd38e0317a Re-enable SonarCloud with correct secret name SONARCLOUD_GITHUB
- Changed from SONAR_TOKEN to SONARCLOUD_GITHUB
- Re-enabled automatic triggers on push/PR
- Removed continue-on-error since token is now configured
2025-11-24 21:34:28 +00:00

57 lines
1.8 KiB
YAML

name: SonarCloud Analysis
on:
push:
branches: [ main, feature/* ]
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened]
workflow_dispatch:
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Check if SonarCloud token is set
id: check_token
run: |
if [ -z "${{ secrets.SONARCLOUD_GITHUB }}" ]; then
echo "SONARCLOUD_GITHUB is not set, skipping SonarCloud analysis"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: SonarCloud Scan
if: steps.check_token.outputs.skip != 'true'
uses: SonarSource/sonarqube-scan-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_GITHUB }}
with:
args: >
-Dsonar.projectKey=wpallstars_wp-plugin-starter-template-for-ai-coding
-Dsonar.organization=wpallstars
-Dsonar.sources=.
-Dsonar.tests=tests
-Dsonar.sourceEncoding=UTF-8
-Dsonar.cpd.exclusions=tests/**
-Dsonar.exclusions=vendor/**,node_modules/**,tests/**,bin/**,build/**,dist/**,.github/**,.git/**,cypress/**,playground/**,.wiki/**
-Dsonar.php.coverage.reportPaths=coverage.xml
-Dsonar.php.tests.reportPath=test-report.xml