odex25_standard/.github/workflows/sonarqube.yml

81 lines
2.3 KiB
YAML

name: SonarQube Analysis
on:
push:
branches:
- master_odex-event
- master_odex25_accounting
- master_odex25_base
- master_odex25_dms
- master_odex25_fleet
- master_odex25_helpdesk
- master_odex25_hr
- master_odex25_inventory
- master_odex25_maintenance
- master_odex25_mobile
- master_odex25_pos
- master_odex25_project
- master_odex25_purchase
- master_odex25_realstate
- master_odex25_sales
- master_odex25_survey
- master_odex25_transactions
- master_odex25_website
- master_openeducat_erp-14.0.1.0
- master_odex25_ensan
- master_odex25_donation
pull_request:
branches:
- "**"
jobs:
sonar:
runs-on: sonarqube
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run SonarScanner
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
BRANCH_NAME="${GITHUB_HEAD_REF}"
BASE_BRANCH="${GITHUB_BASE_REF}"
PR_KEY="${{ github.event.pull_request.number }}"
else
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
fi
SONAR_HOST_URL=${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}
echo "Running SonarQube analysis for branch/PR: $BRANCH_NAME"
SONAR_CMD="sonar-scanner \
-Dsonar.projectKey=odex25_standard_modules \
-Dsonar.projectName=\"Odex25 Standard Modules\" \
-Dsonar.sources=. \
-Dsonar.inclusions=**/*.py,**/*.xml,**/*.js,**/*.html,**/*.css \
-Dsonar.exclusions=**/__manifest__.py,**/migrations/**,**/__pycache__/** \
-Dsonar.sourceEncoding=UTF-8 \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_TOKEN"
if [ "${{ github.event_name }}" == "pull_request" ]; then
SONAR_CMD="$SONAR_CMD \
-Dsonar.pullrequest.key=$PR_KEY \
-Dsonar.pullrequest.branch=$BRANCH_NAME \
-Dsonar.pullrequest.base=$BASE_BRANCH"
else
SONAR_CMD="$SONAR_CMD \
-Dsonar.branch.name=$BRANCH_NAME"
fi
eval $SONAR_CMD
- name: Cleanup workspace
if: always()
run: |
rm -rf $GITHUB_WORKSPACE/*