Skip to content

Commit 80009a1

Browse files
authored
Add support for non-root package.json for version calculation in Sonar workflow (#5240)
* Add support for non-root package.json for version calculation in Sonar workflow * Fix version_cmd
1 parent 93e6c95 commit 80009a1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

.github/workflows/sonarcloud.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ on:
1313
type: boolean
1414
required: false
1515
description: "Whether to combine multiple LCOV and sonar-report files in coverage artifact"
16+
version-pkg-json-dir:
17+
type: string
18+
default: "."
19+
description: "Relative path of the directory containing package.json with the `version` to use."
1620
permissions: {}
1721
jobs:
1822
sonarqube:
@@ -84,7 +88,7 @@ jobs:
8488
repository: ${{ github.event.workflow_run.head_repository.full_name }}
8589
is_pr: ${{ github.event.workflow_run.event == 'pull_request' }}
8690
skip_coverage_label: Z-Skip-Coverage
87-
version_cmd: "cat package.json | jq -r .version"
91+
version_cmd: "cat ${{ inputs.version-pkg-json-dir }}/package.json | jq -r .version"
8892
branch: ${{ github.event.workflow_run.head_branch }}
8993
revision: ${{ github.event.workflow_run.head_sha }}
9094
token: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)