From dd735cbd34a500335d96557cc95241f1f6fe0460 Mon Sep 17 00:00:00 2001 From: Rajendra Reddy Date: Mon, 30 Mar 2026 02:39:41 +0000 Subject: [PATCH] Add .gitea/workflows/sonarscan.yml --- .gitea/workflows/sonarscan.yml | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .gitea/workflows/sonarscan.yml diff --git a/.gitea/workflows/sonarscan.yml b/.gitea/workflows/sonarscan.yml new file mode 100644 index 0000000..be6cc43 --- /dev/null +++ b/.gitea/workflows/sonarscan.yml @@ -0,0 +1,64 @@ +name: SonarQube Quality Gate + +on: + push: + branches: + - testing + - main + + pull_request: + branches: + - testing + - main + +env: + SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }} + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + +jobs: + sonarqube: + name: SonarQube Scan + runs-on: ubuntu-latest + + container: + image: sonarsource/sonar-scanner-cli:latest + options: --user root + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set project metadata + run: | + echo "PROJECT_KEY=${{ gitea.repository }}" >> $GITHUB_ENV + echo "PROJECT_NAME=${{ gitea.repository }}" >> $GITHUB_ENV + + - name: Run SonarQube Scan + run: | + sonar-scanner \ + -Dsonar.projectKey=$PROJECT_KEY \ + -Dsonar.projectName=$PROJECT_NAME \ + -Dsonar.sources=. \ + -Dsonar.host.url=$SONAR_HOST_URL \ + -Dsonar.token=$SONAR_TOKEN \ + -Dsonar.exclusions=node_modules/**,dist/**,coverage/** \ + -Dsonar.qualitygate.wait=true \ + -Dsonar.branch.name=${{ gitea.ref_name }} + + # PR-specific configuration + - name: SonarQube PR Analysis + if: gitea.event_name == 'pull_request' + run: | + sonar-scanner \ + -Dsonar.projectKey=$PROJECT_KEY \ + -Dsonar.projectName=$PROJECT_NAME \ + -Dsonar.sources=. \ + -Dsonar.host.url=$SONAR_HOST_URL \ + -Dsonar.token=$SONAR_TOKEN \ + -Dsonar.exclusions=node_modules/**,dist/**,coverage/** \ + -Dsonar.qualitygate.wait=true \ + -Dsonar.pullrequest.key=${{ gitea.event.pull_request.number }} \ + -Dsonar.pullrequest.branch=${{ gitea.head_ref }} \ + -Dsonar.pullrequest.base=${{ gitea.base_ref }} \ No newline at end of file