11---
22name : Build Gradle
3- description : GitHub Action to build, analyze, and deploy a Gradle project with SonarQube integration
3+ description : GitHub Action to build, analyze, and deploy a Gradle project
44inputs :
5- public :
6- description : Deprecated. Use `artifactory-reader-role`, `artifactory-deployer-role`, and `artifactory-deploy-repo` instead.
7- default : ${{ github.event.repository.visibility == 'public' && 'true' || 'false' }}
8- artifactory-deploy-repo :
9- description : Deployment repository. Defaults to `sonarsource-private-qa` for private repositories, and `sonarsource-public-qa` for
10- public repositories.
11- default : ' '
12- artifactory-reader-role :
13- description : Suffix for the Artifactory reader role in Vault. Defaults to `private-reader` for private repositories,
14- and `public-reader` for public repositories.
15- default : ' '
165 artifactory-deployer-role :
176 description : Suffix for the Artifactory deployer role in Vault. Defaults to `qa-deployer` for private repositories, and
187 ` public-deployer` for public repositories.
198 default : ' '
9+ artifactory-deploy-repo :
10+ description : Deployment repository. Defaults to `sonarsource-private-qa` for private repositories, and `sonarsource-public-qa` for
11+ public repositories.
12+ default : ' '
2013 gradle-args :
2114 description : Additional arguments to pass to Gradle
2215 deploy :
@@ -28,52 +21,57 @@ inputs:
2821 skip-tests :
2922 description : Whether to skip running tests
3023 default : ' false'
31- use-develocity :
32- description : Whether to use Develocity for build tracking.
24+ sonar-platform :
25+ description : SonarQube primary platform (next, sqc-eu, sqc-us, or none). Use 'none' to skip sonar scans.
26+ default : next
27+ run-shadow-scans :
28+ description : If true, run SonarQube analysis on all three platforms (next, sqc-eu, sqc-us).
29+ If false, run analysis on the platform specified with sonar-platform.
3330 default : ' false'
34- develocity-url :
35- description : URL for Develocity
36- default : https://develocity.sonar.build/
31+ provenance :
32+ description : Whether to generate provenance attestation for built artifacts
33+ default : ' false'
34+ provenance-artifact-paths :
35+ description : >-
36+ Relative paths of the artifacts for which to generate a provenance attestation (glob pattern).
37+ Default is collected from '*/build/libs/*', '*/build/distributions/*', and '*/build/reports/*'
38+ default : ' '
39+ # Inputs passed to config-gradle
40+ working-directory :
41+ description : Relative path under github.workspace to execute the build in
42+ default : .
43+ artifactory-reader-role :
44+ description : Suffix for the Artifactory reader role in Vault. Defaults to `private-reader` for private repositories, and `public-reader`
45+ for public repositories.
46+ default : ' '
3747 repox-url :
3848 description : URL for Repox
3949 default : https://repox.jfrog.io
4050 repox-artifactory-url :
4151 description : URL for Repox Artifactory API (overrides repox-url/artifactory if provided)
4252 default : ' '
43- sonar-platform :
44- description : SonarQube variant (next, sqc-eu, sqc-us, or none). Use 'none' to skip sonar scans.
45- default : next
46- working-directory :
47- description : Relative path under github.workspace to execute the build in
48- default : .
49- run-shadow-scans :
50- description : If true, run sonar scanner on all 3 platforms using the provided URL and token.
51- If false, run on the platform provided by SONAR_PLATFORM.
53+ use-develocity :
54+ description : Whether to use Develocity for build tracking.
5255 default : ' false'
56+ develocity-url :
57+ description : URL for Develocity
58+ default : https://develocity.sonar.build/
5359 cache-paths :
54- description : Cache paths to use (multiline). If provided, overrides the default Gradle cache directories
60+ description : Cache paths to use (multiline).
5561 default : |-
5662 ~/.gradle/caches
5763 ~/.gradle/wrapper
5864 disable-caching :
5965 description : Whether to disable Gradle caching entirely
6066 default : ' false'
61- provenance :
62- description : Whether to generate provenance attestation for built artifacts
63- default : ' false'
64- provenance-artifact-paths :
65- description : >-
66- Relative paths of the artifacts for which to generate a provenance attestation (glob pattern).
67- Default is collected from '*/build/libs/*', '*/build/distributions/*', and '*/build/reports/*'
68- default : ' '
6967
7068outputs :
7169 project-version :
7270 description : The release version set as Gradle project version in gradle.properties
73- value : ${{ steps.config-gradle .outputs.project-version }}
71+ value : ${{ steps.config.outputs.project-version }}
7472 BUILD_NUMBER :
7573 description : The build number, incremented or reused if already cached
76- value : ${{ steps.config-gradle .outputs.BUILD_NUMBER }}
74+ value : ${{ steps.config.outputs.BUILD_NUMBER }}
7775 deployed :
7876 description : Whether artifacts were deployed
7977 value : ${{ steps.build.outputs.deployed }}
@@ -103,6 +101,19 @@ runs:
103101 ls -la .actions/*
104102 echo "::endgroup::"
105103
104+ - uses : ./.actions/config-gradle
105+ id : config
106+ with :
107+ host-actions-root : ${{ steps.set-path.outputs.host_actions_root }}
108+ working-directory : ${{ inputs.working-directory }}
109+ artifactory-reader-role : ${{ inputs.artifactory-reader-role }}
110+ repox-url : ${{ inputs.repox-url }}
111+ repox-artifactory-url : ${{ inputs.repox-artifactory-url }}
112+ use-develocity : ${{ inputs.use-develocity }}
113+ develocity-url : ${{ inputs.develocity-url }}
114+ cache-paths : ${{ inputs.cache-paths }}
115+ disable-caching : ${{ inputs.disable-caching }}
116+
106117 - name : Set build parameters
107118 shell : bash
108119 env :
@@ -128,38 +139,9 @@ runs:
128139 development/kv/data/sign key_id | SIGN_KEY_ID;
129140 # yamllint enable rule:line-length
130141
131- - name : Setup environment for deployment
132- shell : bash
133- env :
134- # Deployment secrets
135- ARTIFACTORY_DEPLOY_USERNAME : ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_DEPLOY_USERNAME }}
136- ARTIFACTORY_DEPLOY_ACCESS_TOKEN : ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_DEPLOY_ACCESS_TOKEN }}
137- ARTIFACTORY_DEPLOY_REPO : ${{ inputs.artifactory-deploy-repo != '' && inputs.artifactory-deploy-repo ||
138- github.event.repository.visibility == 'public' && 'sonarsource-public-qa' || 'sonarsource-private-qa' }}
139- run : |
140- echo "ARTIFACTORY_DEPLOY_USERNAME=$ARTIFACTORY_DEPLOY_USERNAME" >> "$GITHUB_ENV"
141- echo "ARTIFACTORY_DEPLOY_ACCESS_TOKEN=$ARTIFACTORY_DEPLOY_ACCESS_TOKEN" >> "$GITHUB_ENV"
142- echo "ARTIFACTORY_DEPLOY_PASSWORD=$ARTIFACTORY_DEPLOY_ACCESS_TOKEN" >> "$GITHUB_ENV" # deprecated, backward compliance
143- echo "ARTIFACTORY_DEPLOY_REPO=${ARTIFACTORY_DEPLOY_REPO}" >> "$GITHUB_ENV"
144-
145- - name : Configure Gradle
146- uses : ./.actions/config-gradle
147- id : config-gradle
148- with :
149- host-actions-root : ${{ steps.set-path.outputs.host_actions_root }}
150- working-directory : ${{ inputs.working-directory }}
151- artifactory-reader-role : ${{ inputs.artifactory-reader-role }}
152- use-develocity : ${{ inputs.use-develocity }}
153- develocity-url : ${{ inputs.develocity-url }}
154- repox-url : ${{ inputs.repox-url }}
155- repox-artifactory-url : ${{ inputs.repox-artifactory-url }}
156- cache-paths : ${{ inputs.cache-paths }}
157- disable-caching : ${{ inputs.disable-caching }}
158-
159142 - name : Build, analyze and deploy
160- id : build
161143 shell : bash
162- working-directory : ${{ inputs.working-directory }}
144+ id : build
163145 env :
164146 # GitHub context
165147 PULL_REQUEST : ${{ github.event.pull_request.number || '' }}
@@ -171,20 +153,24 @@ runs:
171153 DEPLOY_PULL_REQUEST : ${{ inputs.deploy-pull-request }}
172154 SKIP_TESTS : ${{ inputs.skip-tests }}
173155 GRADLE_ARGS : ${{ inputs.gradle-args }}
156+ SONAR_PLATFORM : ${{ inputs.sonar-platform }}
157+ RUN_SHADOW_SCANS : ${{ inputs.run-shadow-scans }}
158+ ARTIFACTORY_DEPLOY_REPO : ${{ inputs.artifactory-deploy-repo != '' && inputs.artifactory-deploy-repo ||
159+ github.event.repository.visibility == 'public' && 'sonarsource-public-qa' || 'sonarsource-private-qa' }}
174160
175- # Vault secrets - always fetch all platforms
161+ # Vault secrets
162+ ARTIFACTORY_DEPLOY_USERNAME : ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_DEPLOY_USERNAME }}
163+ ARTIFACTORY_DEPLOY_ACCESS_TOKEN : ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_DEPLOY_ACCESS_TOKEN }}
176164 NEXT_URL : ${{ fromJSON(steps.secrets.outputs.vault).NEXT_URL }}
177165 NEXT_TOKEN : ${{ fromJSON(steps.secrets.outputs.vault).NEXT_TOKEN }}
178- SQC_US_URL : ${{ fromJSON(steps.secrets.outputs.vault).SQC_US_URL }}
179- SQC_US_TOKEN : ${{ fromJSON(steps.secrets.outputs.vault).SQC_US_TOKEN }}
180166 SQC_EU_URL : ${{ fromJSON(steps.secrets.outputs.vault).SQC_EU_URL }}
181167 SQC_EU_TOKEN : ${{ fromJSON(steps.secrets.outputs.vault).SQC_EU_TOKEN }}
182- SONAR_PLATFORM : ${{ inputs.sonar-platform }}
183- RUN_SHADOW_SCANS : ${{ inputs.run-shadow-scans }}
184-
168+ SQC_US_URL : ${{ fromJSON(steps.secrets.outputs.vault).SQC_US_URL }}
169+ SQC_US_TOKEN : ${{ fromJSON(steps.secrets.outputs.vault).SQC_US_TOKEN }}
185170 ORG_GRADLE_PROJECT_signingKey : ${{ fromJSON(steps.secrets.outputs.vault).SIGN_KEY }}
186171 ORG_GRADLE_PROJECT_signingPassword : ${{ fromJSON(steps.secrets.outputs.vault).PGP_PASSPHRASE }}
187172 ORG_GRADLE_PROJECT_signingKeyId : ${{ fromJSON(steps.secrets.outputs.vault).SIGN_KEY_ID }}
173+ working-directory : ${{ inputs.working-directory }}
188174 run : ${GITHUB_ACTION_PATH}/build.sh
189175
190176 - name : Archive problems report
@@ -194,6 +180,7 @@ runs:
194180 name : problems-report-${{ github.job }}${{ strategy.job-index }}
195181 path : build/reports/problems/problems-report.html
196182 if-no-files-found : ignore
183+
197184 - name : Generate provenance attestation
198185 if : >-
199186 ${{ inputs.provenance == 'true' &&
@@ -209,9 +196,6 @@ runs:
209196 - name : Generate workflow summary
210197 if : always()
211198 shell : bash
212- env :
213- ARTIFACTORY_URL : ${{ inputs.repox-artifactory-url != '' && inputs.repox-artifactory-url ||
214- format('{0}/artifactory', inputs.repox-url) }}
215199 run : |
216200 build_name="${GITHUB_REPOSITORY#*/}"
217201 echo "## 🏗️ Gradle Build Summary" >> $GITHUB_STEP_SUMMARY
0 commit comments