Update github action file

This commit is contained in:
شركة خبير المحدودة 2025-09-27 21:25:28 +03:00
parent 16e2cd9e88
commit 4e2a6d586c
1 changed files with 39 additions and 20 deletions

View File

@ -24,7 +24,9 @@ on:
- master_openeducat_erp-14.0.1.0 - master_openeducat_erp-14.0.1.0
- master_odex25_ensan - master_odex25_ensan
- master_odex25_donation - master_odex25_donation
pull_request:
branches:
- "**"
jobs: jobs:
sonar: sonar:
@ -32,28 +34,45 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run SonarScanner - name: Run SonarScanner
run: | run: |
export BRANCH_NAME="${GITHUB_REF#refs/heads/}" if [ "${{ github.event_name }}" == "pull_request" ]; then
export SAFE_BRANCH_NAME="${BRANCH_NAME//\//_}" BRANCH_NAME="${GITHUB_HEAD_REF}"
export PROJECT_KEY="odex25_standard_modules_${SAFE_BRANCH_NAME}" BASE_BRANCH="${GITHUB_BASE_REF}"
export PROJECT_NAME="Standard Modules ${SAFE_BRANCH_NAME^}" PR_KEY="${{ github.event.pull_request.number }}"
export SOURCE_FOLDER_NAME="${BRANCH_NAME#master_}" else
export PROJECT_VERSION="1.0" BRANCH_NAME="${GITHUB_REF#refs/heads/}"
export SONAR_HOST_URL=${{ secrets.SONAR_HOST_URL }} fi
export SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}
sonar-scanner \ SONAR_HOST_URL=${{ secrets.SONAR_HOST_URL }}
-Dsonar.projectKey="$PROJECT_KEY" \ SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}
-Dsonar.projectName="$PROJECT_NAME" \
-Dsonar.projectVersion="$PROJECT_VERSION" \ echo "Running SonarQube analysis for branch/PR: $BRANCH_NAME"
-Dsonar.sources="$SOURCE_FOLDER_NAME" \
-Dsonar.inclusions="**/*.py, **/*.xml, **/*.js, **/*.html, **/*.css" \ SONAR_CMD="sonar-scanner \
-Dsonar.exclusions="**/__manifest__.py, **/migrations/**, **/__pycache__/**" \ -Dsonar.projectKey=odex25_standard_modules \
-Dsonar.sourceEncoding="UTF-8" \ -Dsonar.projectName=\"Odex25 Standard Modules\" \
-Dsonar.host.url="$SONAR_HOST_URL" \ -Dsonar.sources=. \
-Dsonar.login="$SONAR_TOKEN" -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 - name: Cleanup workspace
if: always() if: always()