@@ -33,7 +33,13 @@ inputs:
3333outputs :
3434 BUILD_NUMBER :
3535 description : The build number, incremented or reused if already cached
36- value : ${{ steps.get_build_number.outputs.BUILD_NUMBER }}
36+ value : ${{ steps.get-build-number.outputs.BUILD_NUMBER }}
37+ current-version :
38+ description : The project version set in the gradle.properties (before replacement). Also set as environment variable CURRENT_VERSION
39+ value : ${{ steps.set-version.outputs.current-version }}
40+ project-version :
41+ description : The project version with build number (after replacement). Also set as environment variable PROJECT_VERSION
42+ value : ${{ steps.set-version.outputs.project-version }}
3743
3844runs :
3945 using : composite
@@ -63,12 +69,20 @@ runs:
6369 echo "::endgroup::"
6470
6571 - name : Get build number
66- id : get_build_number
72+ id : get-build-number
6773 uses : ./.actions/get-build-number
6874 with :
6975 host-actions-root : ${{ steps.set-path.outputs.host_actions_root }}
7076
77+ - id : config-gradle-completed
78+ if : env.CONFIG_GRADLE_COMPLETED != ''
79+ shell : bash
80+ run : |
81+ echo "Action already called by $CONFIG_GRADLE_COMPLETED, execution skipped."
82+ echo "skip=true" >> $GITHUB_OUTPUT
83+
7184 - name : Set parameter for Vault
85+ if : steps.config-gradle-completed.outputs.skip != 'true'
7286 shell : bash
7387 env :
7488 ARTIFACTORY_READER_ROLE : ${{ inputs.artifactory-reader-role != '' && inputs.artifactory-reader-role ||
7892
7993 - name : Get secrets from Vault
8094 id : secrets
95+ if : steps.config-gradle-completed.outputs.skip != 'true'
8196 uses : SonarSource/vault-action-wrapper@320bd31b03e5dacaac6be51bbbb15adf7caccc32 # 3.1.0
8297 with :
8398 secrets : |
86101 ${{ inputs.use-develocity == 'true' && 'development/kv/data/develocity token | DEVELOCITY_TOKEN;' || '' }}
87102
88103 - name : Set environment variables for Artifactory authentication
104+ if : steps.config-gradle-completed.outputs.skip != 'true'
89105 shell : bash
90106 env :
91107 ARTIFACTORY_URL :
@@ -117,14 +133,15 @@ runs:
117133
118134 # Configure Gradle for comprehensive caching and build summary reporting. It does not install Gradle.
119135 - name : Configure Gradle
136+ if : steps.config-gradle-completed.outputs.skip != 'true'
120137 uses : gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4
121138 with :
122139 develocity-injection-enabled : ${{ inputs.use-develocity == 'true' }}
123140 cache-disabled : true
124141 develocity-plugin-version : ' 4.0'
125142
126143 - name : Generate Gradle Cache Key
127- if : ${{ inputs.disable-caching != 'true' }}
144+ if : steps.config-gradle-completed.outputs.skip != 'true' && inputs.disable-caching != 'true'
128145 shell : bash
129146 run : |
130147 # Generate cache key from all Gradle files
@@ -139,7 +156,7 @@ runs:
139156 rm -f gradle-md5-sums.txt
140157
141158 - name : Restore Gradle Cache
142- if : ${{ inputs.disable-caching != 'true' }}
159+ if : steps.config-gradle-completed.outputs.skip != 'true' && inputs.disable-caching != 'true'
143160 uses : SonarSource/gh-action_cache@v1
144161 id : gradle-cache-restore
145162 with :
@@ -150,22 +167,34 @@ runs:
150167
151168 # $GRADLE_USER_HOME is typically set to ~/.gradle/ by gradle/actions/setup-gradle
152169 - name : Configure Gradle Authentication
170+ if : steps.config-gradle-completed.outputs.skip != 'true'
153171 shell : bash
154172 run : |
155173 GRADLE_INIT_DIR="$GRADLE_USER_HOME/init.d"
156174 mkdir -p "$GRADLE_INIT_DIR"
157175 cp "${GITHUB_ACTION_PATH}/resources/repoxAuth.init.gradle.kts" "$GRADLE_INIT_DIR/"
158176
177+ - name : Update project version and set current-version and project-version variables
178+ id : set-version
179+ if : steps.config-gradle-completed.outputs.skip != 'true' && (env.CURRENT_VERSION == '' || env.PROJECT_VERSION == '')
180+ shell : bash
181+ run : ${GITHUB_ACTION_PATH}/set_gradle_project_version.sh
182+
159183 - name : Extract Develocity hostname
160184 id : develocity-hostname
161- if : ${{ inputs.use-develocity == 'true' }}
185+ if : steps.config-gradle-completed.outputs.skip != 'true' && inputs.use-develocity == 'true'
162186 shell : bash
163187 run : echo "hostname=$(echo '${{ inputs.develocity-url }}' | sed 's|https://||' | sed 's|/$||')" >> $GITHUB_OUTPUT
164188
165189 - name : Deactivate UseContainerSupport on github-ubuntu-* runners
166- if : runner.os == 'Linux' && runner.environment == 'github-hosted'
190+ if : steps.config-gradle-completed.outputs.skip != 'true' && runner.os == 'Linux' && runner.environment == 'github-hosted'
167191 shell : bash
168192 run : |
169193 echo "::warning title=Deactivating UseContainerSupport::The GitHub-hosted Ubuntu runners have an issue with Java's" \
170194 "UseContainerSupport feature."
171195 echo "JAVA_TOOL_OPTIONS=${JAVA_TOOL_OPTIONS:=-XX:-UseContainerSupport}" >> "$GITHUB_ENV"
196+
197+ - name : Set Config Gradle completed
198+ if : steps.config-gradle-completed.outputs.skip != 'true'
199+ shell : bash
200+ run : echo "CONFIG_GRADLE_COMPLETED=$GITHUB_ACTION" >> "$GITHUB_ENV"
0 commit comments