Enhance CI workflow with versioning and SonarQube analysis

Added steps to get project version from Git tag and perform SonarQube analysis for both pull requests and branches.
This commit is contained in:
Enno Gelhaus 2025-09-30 14:58:55 +02:00 committed by GitHub
parent df4475eaaf
commit 1aeebfce8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 34 additions and 0 deletions

View File

@ -21,6 +21,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v2
@ -48,3 +49,36 @@ jobs:
- name: Build
run: pnpm run build
- name: Get Project Version from Git Tag
id: get_version
run: |
# Use 'git describe' to find the closest tag, falling back to the commit SHA if no tag is found.
# --tags includes all tags, --always ensures it always outputs something.
VERSION=$(git describe --tags --always)
echo "Project version is $VERSION"
echo "tag=$VERSION" >> $GITHUB_OUTPUT
- name: SonarQube Analysis (Pull Request)
uses: SonarSource/sonarqube-scan-action@v6
if: always() && github.event_name == 'pull_request'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_PULL_REQUEST_KEY: ${{ github.event.pull_request.number }}
SONAR_PULL_REQUEST_BRANCH: ${{ github.head_ref }}
SONAR_PULL_REQUEST_BASE: ${{ github.base_ref }}
with:
args: >
-Dsonar.projectVersion=${{ steps.get_version.outputs.tag }}
- name: SonarQube Analysis (Branch)
uses: SonarSource/sonarqube-scan-action@v6
if: always() && github.event_name != 'pull_request'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
with:
args: >
-Dsonar.projectVersion=${{ steps.get_version.outputs.tag }}