Skip to content

Commit baa621a

Browse files
refactor: Extract the setup-java action into a re-usable action (eclipse-tractusx#246)
* Extract the checkout and setup-java action into a re-usable action * Commit actions. * fix action * remove checkout extraction
1 parent f6b877c commit baa621a

14 files changed

+71
-150
lines changed

.github/actions/publish-docker-image/action.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ inputs:
4141
runs:
4242
using: "composite"
4343
steps:
44-
- name: Checkout
45-
uses: actions/checkout@v3
44+
- uses: actions/checkout@v3.3.0
4645

4746
#####################
4847
# Login to DockerHub
@@ -56,12 +55,7 @@ runs:
5655
#####################
5756
# Build JAR file
5857
#####################
59-
- name: Set up JDK 11
60-
uses: actions/setup-java@v3.11.0
61-
with:
62-
java-version: '17'
63-
distribution: 'temurin'
64-
cache: 'gradle'
58+
- uses: ./.github/actions/setup-java
6559
- name: Build Controlplane
6660
shell: bash
6761
run: |-

.github/actions/run-deployment-test/action.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,15 @@ inputs:
4242
runs:
4343
using: "composite"
4444
steps:
45-
- name: Checkout
46-
uses: actions/checkout@v3.3.0
45+
- uses: actions/checkout@v3.3.0
4746

4847
- name: Cache ContainerD Image Layers
4948
uses: actions/cache@v3
5049
with:
5150
path: /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs
5251
key: ${{ runner.os }}-io.containerd.snapshotter.v1.overlayfs
5352

54-
- name: Set up JDK 11
55-
uses: actions/setup-java@v3.11.0
56-
with:
57-
java-version: '11'
58-
distribution: 'temurin'
59-
cache: 'gradle'
53+
- uses: ./.github/actions/setup-java
6054

6155
- name: Build docker images
6256
shell: bash

.github/actions/setup-java/action.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
3+
# Copyright (c) 2023 Contributors to the Eclipse Foundation
4+
#
5+
# See the NOTICE file(s) distributed with this work for additional
6+
# information regarding copyright ownership.
7+
#
8+
# This program and the accompanying materials are made available under the
9+
# terms of the Apache License, Version 2.0 which is available at
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
20+
21+
---
22+
name: "Setup JDK 17"
23+
description: "Setup JDK 17"
24+
runs:
25+
using: "composite"
26+
steps:
27+
- name: Setup JDK 17
28+
uses: actions/setup-java@v3.11.0
29+
with:
30+
java-version: '17'
31+
distribution: 'temurin'
32+
cache: 'gradle'

.github/workflows/build.yaml

+6-20
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,8 @@ jobs:
7171
needs: [ secret-presence ]
7272
steps:
7373
# Set-Up
74-
- name: Checkout
75-
uses: actions/checkout@v3.3.0
76-
- name: Set up JDK 11
77-
uses: actions/setup-java@v3.11.0
78-
with:
79-
java-version: '17'
80-
distribution: 'temurin'
81-
cache: 'gradle'
74+
- uses: actions/checkout@v3.3.0
75+
- uses: ./.github/actions/setup-java
8276
# Build
8377
- name: Build Extensions
8478
run: |-
@@ -104,8 +98,7 @@ jobs:
10498
permissions:
10599
contents: write
106100
steps:
107-
- name: Checkout
108-
uses: actions/checkout@v3
101+
- uses: actions/checkout@v3.3.0
109102
- uses: ./.github/actions/publish-docker-image
110103
with:
111104
rootDir: edc-controlplane/${{ matrix.name }}
@@ -128,8 +121,7 @@ jobs:
128121
permissions:
129122
contents: write
130123
steps:
131-
- name: Checkout
132-
uses: actions/checkout@v3
124+
- uses: actions/checkout@v3.3.0
133125
- uses: ./.github/actions/publish-docker-image
134126
with:
135127
rootDir: edc-dataplane/${{ matrix.name }}
@@ -149,15 +141,9 @@ jobs:
149141
needs.secret-presence.outputs.GPG_PASSPHRASE && needs.secret-presence.outputs.GPG_PRIVATE_KEY && github.event_name != 'pull_request' && github.ref != 'refs/heads/releases'
150142
steps:
151143
# Set-Up
152-
- name: Checkout
153-
uses: actions/checkout@v3.3.0
144+
- uses: actions/checkout@v3.3.0
154145

155-
- name: Set up JDK 11
156-
uses: actions/setup-java@v3.11.0
157-
with:
158-
java-version: '17'
159-
distribution: 'temurin'
160-
cache: 'gradle'
146+
- uses: ./.github/actions/setup-java
161147
- name: Import GPG Key
162148
uses: crazy-max/ghaction-import-gpg@v5
163149
with:

.github/workflows/business-tests.yaml

+1-7
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,9 @@ jobs:
5050
### Set-Up ###
5151
##############
5252
-
53-
name: Checkout
5453
uses: actions/checkout@v3.3.0
5554
-
56-
name: Set-Up JDK 11
57-
uses: actions/setup-java@v3.11.0
58-
with:
59-
java-version: '17'
60-
distribution: 'temurin'
61-
cache: 'gradle'
55+
uses: ./.github/actions/setup-java
6256
-
6357
name: Cache ContainerD Image Layers
6458
uses: actions/cache@v3

.github/workflows/deployment-test.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ jobs:
4747
deployment-test-memory:
4848
runs-on: ubuntu-latest
4949
steps:
50-
- name: Checkout
51-
uses: actions/checkout@v3.3.0
50+
- uses: actions/checkout@v3.3.0
5251
- uses: ./.github/actions/run-deployment-test
5352
name: "Run deployment test using KinD and Helm"
5453
with:

.github/workflows/draft-new-release.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ jobs:
3333
git config user.name "GitHub actions"
3434
git config user.email noreply@github.com
3535
-
36-
name: Set up JDK 11
37-
uses: actions/setup-java@v3.11.0
38-
with:
39-
java-version: '17'
40-
distribution: 'temurin'
41-
cache: 'gradle'
36+
uses: ./.github/actions/setup-java
4237
-
4338
name: Bump version in gradle.properties
4439
run: |-

.github/workflows/helm-chart-release.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ jobs:
3838

3939
steps:
4040
# fetch-depth: 0 is required to determine differences in chart(s)
41-
- name: Checkout
42-
uses: actions/checkout@v3
41+
- uses: actions/checkout@v3.3.0
4342
with:
4443
fetch-depth: 0
4544

.github/workflows/helm-lint.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
### Set-Up ###
2727
##############
2828
-
29-
name: Checkout
3029
uses: actions/checkout@v3.3.0
3130
with:
3231
fetch-depth: 0

.github/workflows/publish-docker.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ jobs:
5050
contents: write
5151
packages: write
5252
steps:
53-
- name: Checkout
54-
uses: actions/checkout@v3
53+
- uses: actions/checkout@v3.3.0
5554
- uses: ./.github/actions/publish-docker-image
5655
with:
5756
rootDir: edc-controlplane/${{ matrix.name }}
@@ -74,8 +73,7 @@ jobs:
7473
contents: write
7574
packages: write
7675
steps:
77-
- name: Checkout
78-
uses: actions/checkout@v3
76+
- uses: actions/checkout@v3.3.0
7977
- uses: ./.github/actions/publish-docker-image
8078
with:
8179
rootDir: edc-dataplane/${{ matrix.name }}

.github/workflows/publish-new-release.yml

+2-15
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,9 @@ jobs:
5454
run: |
5555
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
5656
-
57-
name: Checkout
5857
uses: actions/checkout@v3.3.0
5958
-
60-
name: Set up JDK 11
61-
uses: actions/setup-java@v3.11.0
62-
with:
63-
java-version: '17'
64-
distribution: 'temurin'
65-
cache: 'gradle'
59+
uses: ./.github/actions/setup-java
6660

6761
- name: Import GPG Key
6862
uses: crazy-max/ghaction-import-gpg@v5
@@ -96,7 +90,6 @@ jobs:
9690
run: |
9791
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
9892
-
99-
name: Checkout
10093
uses: actions/checkout@v3.3.0
10194
with:
10295
fetch-depth: 0
@@ -144,7 +137,6 @@ jobs:
144137
run: |
145138
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
146139
-
147-
name: Checkout
148140
uses: actions/checkout@v3.3.0
149141
with:
150142
# 0 to fetch the full history due to upcoming merge of releases into main branch
@@ -177,12 +169,7 @@ jobs:
177169
draft: false
178170
prerelease: false
179171
-
180-
name: Set up JDK 11
181-
uses: actions/setup-java@v3.11.0
182-
with:
183-
java-version: '17'
184-
distribution: 'temurin'
185-
cache: 'gradle'
172+
uses: ./.github/actions/setup-java
186173
-
187174
name: Merge releases back into main and set new snapshot version
188175
if: github.event.pull_request.base.ref == 'releases'

.github/workflows/trivy.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ jobs:
3636
contents: read
3737
security-events: write
3838
steps:
39-
- name: Checkout repository
40-
uses: actions/checkout@v3.3.0
39+
- uses: actions/checkout@v3.3.0
4140
- name: Run Trivy vulnerability scanner in repo mode
4241
uses: aquasecurity/trivy-action@master
4342
with:
@@ -72,8 +71,7 @@ jobs:
7271
- edc-dataplane-azure-vault
7372
- edc-dataplane-hashicorp-vault
7473
steps:
75-
- name: Checkout
76-
uses: actions/checkout@v3.3.0
74+
- uses: actions/checkout@v3.3.0
7775

7876
## This step will fail if the docker images is not found
7977
- name: "Check if image exists"

.github/workflows/veracode.yaml

+6-24
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,10 @@ jobs:
2323
verify-formatting:
2424
runs-on: ubuntu-latest
2525
steps:
26-
- name: Checkout
27-
uses: actions/checkout@v3.3.0
26+
- uses: actions/checkout@v3.3.0
2827
with:
2928
fetch-depth: 0
30-
- name: Set up JDK 11
31-
uses: actions/setup-java@v3.11.0
32-
with:
33-
java-version: '17'
34-
distribution: 'temurin'
35-
cache: 'gradle'
29+
- uses: ./.github/actions/setup-java
3630
- name: Verify proper formatting
3731
run: ./gradlew spotlessCheck
3832

@@ -51,14 +45,8 @@ jobs:
5145
- edc-controlplane-postgresql-hashicorp-vault
5246
steps:
5347
# Set-Up
54-
- name: Checkout
55-
uses: actions/checkout@v3.3.0
56-
- name: Set up JDK 11
57-
uses: actions/setup-java@v3.11.0
58-
with:
59-
java-version: '17'
60-
distribution: 'temurin'
61-
cache: 'gradle'
48+
- uses: actions/checkout@v3.3.0
49+
- uses: ./.github/actions/setup-java
6250
# Build
6351
- name: Build Controlplane
6452
run: |-
@@ -95,14 +83,8 @@ jobs:
9583
- edc-dataplane-hashicorp-vault
9684
steps:
9785
# Set-Up
98-
- name: Checkout
99-
uses: actions/checkout@v3.3.0
100-
- name: Set up JDK 11
101-
uses: actions/setup-java@v3.11.0
102-
with:
103-
java-version: '17'
104-
distribution: 'temurin'
105-
cache: 'gradle'
86+
- uses: actions/checkout@v3.3.0
87+
- uses: ./.github/actions/setup-java
10688
# Build
10789
- name: Build Dataplane
10890
run: |-

0 commit comments

Comments
 (0)