Skip to content

Commit 8cf6996

Browse files
authored
Enhance build workflow with versioning and analysis
Added steps to get project version from Git tag and perform SonarQube analysis.
1 parent ed14bd8 commit 8cf6996

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ name: Build static docs
33

44
on:
55
push:
6-
branches: ["main"]
7-
pull_request:
8-
branches: ["main"]
96

107
jobs:
118
build:
129
runs-on: ubuntu-latest
1310

1411
steps:
1512
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
1615

1716
- name: Use Node.js
1817
uses: actions/setup-node@v4
@@ -22,3 +21,21 @@ jobs:
2221

2322
- run: npm ci
2423
- run: npm run build --if-present
24+
25+
- name: Get Project Version from Git Tag
26+
id: get_version
27+
run: |
28+
# Use 'git describe' to find the closest tag, falling back to the commit SHA if no tag is found.
29+
# --tags includes all tags, --always ensures it always outputs something.
30+
VERSION=$(git describe --tags --always)
31+
echo "Project version is $VERSION"
32+
echo "tag=$VERSION" >> $GITHUB_OUTPUT
33+
34+
- name: SonarQube Analysis (Branch)
35+
uses: SonarSource/sonarqube-scan-action@v6
36+
env:
37+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
39+
with:
40+
args: >
41+
-Dsonar.projectVersion=${{ steps.get_version.outputs.tag }}

0 commit comments

Comments
 (0)