Skip to content

Commit 72717d9

Browse files
authored
Merge branch 'main' into 314-check-pr-title
2 parents 117059b + 798bbf1 commit 72717d9

6 files changed

Lines changed: 83 additions & 16 deletions

File tree

.github/workflows/test-action-maven-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ jobs:
2727
- uses: ./action-templates/actions/action-maven-build
2828
with:
2929
app-path: __tests__/maven-helloworld
30+
java-version: "21"

action-templates/actions/action-codeql/action.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ inputs:
1717
required: false
1818
default: "security-and-quality"
1919
java-version:
20-
description: "Temurin JDK version to use for autobuild (only when codeql-language is java-kotlin and codeql-build is set to autobuild)"
20+
description: "Temurin JDK version to use for autobuild (only when codeql-language is java-kotlin and codeql-build is set to autobuild). If not set extract the version from the `pom.xml` on the attribute `java.version`."
2121
required: false
22-
default: "21"
2322
path:
2423
description: "Path to scan files in"
2524
required: false
@@ -32,11 +31,33 @@ runs:
3231
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3332
with:
3433
persist-credentials: false
34+
- name: Extract Java Version from pom.xml
35+
id: get-java-version
36+
if: inputs.codeql-language == 'java-kotlin' && inputs.codeql-buildmode == 'autobuild'
37+
shell: bash
38+
env:
39+
APP_PATH: ${{inputs.path}}
40+
JAVA_VERSION: ${{ inputs.java-version }}
41+
run: |
42+
# Check if the input java-version is empty
43+
if [ -z "$JAVA_VERSION" ]; then
44+
# Extract from pom.xml if input is empty
45+
JAVA_VERSION=$(grep -oP '(?<=<(java.version)>)[^<]+' "$APP_PATH/pom.xml" | head -n 1)
46+
fi
47+
48+
# Fail the build if no version could be determined at all
49+
if [ -z "$JAVA_VERSION" ]; then
50+
echo "Error: Java version could not be determined!"
51+
exit 1
52+
fi
53+
54+
# Save the version to step outputs
55+
echo "java-version=$JAVA_VERSION" >> "$GITHUB_OUTPUT"
3556
- name: Set up JDK
3657
if: inputs.codeql-language == 'java-kotlin' && inputs.codeql-buildmode == 'autobuild'
3758
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
3859
with:
39-
java-version: ${{ inputs.java-version }}
60+
java-version: ${{ steps.get-java-version.outputs.java-version }}
4061
distribution: "temurin"
4162
cache: "maven"
4263
cache-dependency-path: "${{ inputs.path }}/pom.xml"

action-templates/actions/action-filter/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: "Execute paths-filter"
22
description: "Execute paths-filter with input of filters"
33

44
inputs:
5+
base:
6+
description: "Branch, tag, or commit SHA against which the changes will be detected."
7+
required: false
8+
default: ""
59
filters:
610
description: "Defines filters applied to detected changed files"
711
required: false
@@ -41,3 +45,4 @@ runs:
4145
uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
4246
with:
4347
filters: ${{ inputs.filters }}
48+
base: ${{ inputs.base }}

action-templates/actions/action-maven-build/action.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ description: "Executes a Maven build and uploads the generated artifact to Maven
33

44
inputs:
55
java-version:
6-
description: "Java version to use for the build"
6+
description: "Java version to use for the build. If not set extract the version from the `pom.xml` on the attribute `java.version`."
77
required: false
8-
default: "21"
98
app-path:
109
description: "Path to the project’s pom.xml file"
1110
required: true
12-
1311
outputs:
1412
artifact-name:
1513
description: "Name of the artifact upload"
@@ -28,10 +26,32 @@ runs:
2826
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
2927
with:
3028
persist-credentials: false
29+
- name: Extract Java Version from pom.xml
30+
id: get-java-version
31+
shell: bash
32+
env:
33+
APP_PATH: ${{inputs.app-path}}
34+
JAVA_VERSION: ${{ inputs.java-version }}
35+
run: |
36+
# Check if the input java-version is empty
37+
if [ -z "$JAVA_VERSION" ]; then
38+
# Extract from pom.xml if input is empty
39+
JAVA_VERSION=$(grep -oP '(?<=<(java.version)>)[^<]+' "$APP_PATH/pom.xml" | head -n 1)
40+
fi
41+
42+
# Fail the build if no version could be determined at all
43+
if [ -z "$JAVA_VERSION" ]; then
44+
echo "Error: Java version could not be determined!"
45+
exit 1
46+
fi
47+
48+
# Save the version to step outputs
49+
echo "java-version=$JAVA_VERSION" >> "$GITHUB_OUTPUT"
50+
3151
- name: Set up JDK
3252
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
3353
with:
34-
java-version: ${{ inputs.java-version }}
54+
java-version: ${{ steps.get-java-version.outputs.java-version }}
3555
distribution: "temurin"
3656
cache: "maven"
3757
cache-dependency-path: "./${{inputs.app-path}}/pom.xml"

action-templates/actions/action-maven-release/action.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ description: "Creates a Maven release pull request"
33

44
inputs:
55
java-version:
6-
description: "Java version to use for the build"
6+
description: "Java version to use for the build. If not set extract the version from the `pom.xml` on the attribute `java.version`."
77
required: false
8-
default: "21"
98
app-path:
109
description: "Path to the project’s pom.xml file"
1110
required: true
@@ -54,10 +53,31 @@ runs:
5453
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
5554
with:
5655
persist-credentials: true
56+
- name: Extract Java Version from pom.xml
57+
id: get-java-version
58+
shell: bash
59+
env:
60+
APP_PATH: ${{inputs.app-path}}
61+
JAVA_VERSION: ${{ inputs.java-version }}
62+
run: |
63+
# Check if the input java-version is empty
64+
if [ -z "$JAVA_VERSION" ]; then
65+
# Extract from pom.xml if input is empty
66+
JAVA_VERSION=$(grep -oP '(?<=<(java.version)>)[^<]+' "$APP_PATH/pom.xml" | head -n 1)
67+
fi
68+
69+
# Fail the build if no version could be determined at all
70+
if [ -z "$JAVA_VERSION" ]; then
71+
echo "Error: Java version could not be determined!"
72+
exit 1
73+
fi
74+
75+
# Save the version to step outputs
76+
echo "java-version=$JAVA_VERSION" >> "$GITHUB_OUTPUT"
5777
- name: Set up JDK
5878
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
5979
with:
60-
java-version: ${{ inputs.java-version }}
80+
java-version: ${{ steps.get-java-version.outputs.java-version }}
6181
distribution: "temurin"
6282
cache: "maven"
6383
cache-dependency-path: "./${{ inputs.app-path}}/pom.xml"

docs/actions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ Workflows using that action need the following permissions:
271271
filters: |
272272
src:
273273
- 'src/**'
274+
# Branch, tag, or commit SHA against which the changes will be detected.
275+
# default ''
276+
base: ''
274277
275278
# run only if some file in 'src' folder was changed
276279
- if: steps.changes.outputs.src == 'true'
@@ -311,8 +314,7 @@ Workflows using that action need the following permissions:
311314
# Default: security-and-quality
312315
codeql-query: "security-and-quality"
313316
314-
# Temurin JDK version to use for autobuild (only when codeql-language is java-kotlin and codeql-build is set to autobuild)
315-
# Default: 21
317+
# Temurin JDK version to use for autobuild (only when codeql-language is java-kotlin and codeql-build is set to autobuild). If not set extract the version from the `pom.xml` on the attribute `java.version`.
316318
java-version: "21"
317319

318320
# Path to scan files in
@@ -440,8 +442,7 @@ Workflows using that action need the following permissions:
440442
```yaml
441443
- uses: it-at-m/lhm_actions/action-templates/actions/action-maven-build
442444
with:
443-
# Java Version to use
444-
# Default: 21
445+
# Java Version to use. If not set extract the version from the `pom.xml` on the attribute `java.version`.
445446
java-version: "21"
446447

447448
# Path to pom.xml
@@ -476,8 +477,7 @@ Workflows using that action need the following permissions:
476477
```yaml
477478
- uses: it-at-m/lhm_actions/action-templates/actions/action-maven-release
478479
with:
479-
# Java Version to use
480-
# Default: 21
480+
# Java Version to use. If not set extract the version from the `pom.xml` on the attribute `java.version`.
481481
java-version: "21"
482482

483483
# Path to pom.xml

0 commit comments

Comments
 (0)