Skip to content

Commit 18c7cd3

Browse files
authored
ci: modified workflows to pick jdk from respective pom files (#41611)
## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!CAUTION] > If you modify the content in this section, you are likely to disrupt the CI result for your PR. <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Streamlined CI/CD Java environment setup by implementing automatic version detection from project configuration files across all build workflows. * Enhanced deployment configuration to support dynamic Docker image repository and tag selection through environment variables, with fallback values for backward compatibility. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent e61375d commit 18c7cd3

6 files changed

Lines changed: 45 additions & 24 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Setup Server Java"
2+
description: "Sets up JDK using the java.version property from app/server/pom.xml"
3+
4+
inputs:
5+
pom-path:
6+
description: "Path to the pom.xml containing the <java.version> property"
7+
required: false
8+
default: "app/server/pom.xml"
9+
10+
outputs:
11+
java-version:
12+
description: "The Java version that was set up"
13+
value: ${{ steps.extract.outputs.version }}
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Extract Java version from pom.xml
19+
id: extract
20+
shell: bash
21+
run: |
22+
version=$(grep -oP '<java.version>\K[^<]+' "${{ inputs.pom-path }}")
23+
if [[ -z "$version" ]]; then
24+
echo "::error::Could not extract java.version from ${{ inputs.pom-path }}"
25+
exit 1
26+
fi
27+
echo "version=$version" >> $GITHUB_OUTPUT
28+
echo "Detected Java version: $version"
29+
30+
- name: Set up JDK ${{ steps.extract.outputs.version }}
31+
uses: actions/setup-java@v4
32+
with:
33+
distribution: "temurin"
34+
java-version: ${{ steps.extract.outputs.version }}

.github/workflows/github-release.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,8 @@ jobs:
117117
- name: Checkout the code
118118
uses: actions/checkout@v4
119119

120-
- name: Set up JDK 17
121-
uses: actions/setup-java@v4
122-
with:
123-
distribution: "temurin"
124-
java-version: "17"
120+
- name: Set up JDK from dependency file
121+
uses: ./.github/actions/setup-server-java
125122

126123
# Retrieve maven dependencies from cache. After a successful run, these dependencies are cached again
127124
- name: Cache maven dependencies

.github/workflows/server-build.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,8 @@ jobs:
159159
run: echo "I'm alive!" && exit 0
160160

161161
# Setup Java
162-
- name: Set up JDK 17
163-
if: steps.run_result.outputs.run_result != 'success' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')
164-
uses: actions/setup-java@v4
165-
with:
166-
distribution: "temurin"
167-
java-version: "17"
162+
- name: Set up JDK from dependency file
163+
uses: ./.github/actions/setup-server-java
168164

169165
- name: Conditionally start PostgreSQL
170166
if: |

.github/workflows/server-integration-tests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,8 @@ jobs:
5959
uses: actions/checkout@v4
6060

6161
# Setup Java
62-
- name: Set up JDK 17
63-
uses: actions/setup-java@v4
64-
with:
65-
distribution: "temurin"
66-
java-version: "17"
62+
- name: Set up JDK from dependency file
63+
uses: ./.github/actions/setup-server-java
6764

6865
- name: Conditionally start PostgreSQL
6966
if: |

.github/workflows/server-spotless.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ jobs:
2525
ref: refs/pull/${{ inputs.pr }}/merge
2626

2727
# Setup Java
28-
- name: Set up JDK 17
29-
uses: actions/setup-java@v4
30-
with:
31-
distribution: "temurin"
32-
java-version: "17"
33-
28+
- name: Set up JDK from dependency file
29+
uses: ./.github/actions/setup-server-java
30+
3431
# Run maven step for spotless check
3532
- name: Run spotless check
3633
run: mvn spotless:check

scripts/deploy_preview.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ helm show chart appsmith-ee/$HELMCHART || echo "helm show chart failed (non-bloc
9292

9393
echo "Deploying Appsmith Helm chart..."
9494
helm upgrade -i "$CHARTNAME" "appsmith-ee/$HELMCHART" -n "$NAMESPACE" --create-namespace --recreate-pods \
95-
--set _image.repository="$DOCKER_HUB_ORGANIZATION/appsmith-dp" \
96-
--set _image.tag="$IMAGE_HASH" \
95+
--set _image.repository="${IMAGE_REPOSITORY:-$DOCKER_HUB_ORGANIZATION/appsmith-dp}" \
96+
--set _image.tag="${IMAGE_TAG:-$IMAGE_HASH}" \
9797
--set _image.pullPolicy="Always" \
9898
--set image.pullSecrets="$SECRET" \
9999
--set autoscaling.enabled=true \

0 commit comments

Comments
 (0)