Skip to content

Commit

Permalink
refactor: Extract the setup-java action into a re-usable action (ecli…
Browse files Browse the repository at this point in the history
…pse-tractusx#246)

* Extract the checkout and setup-java action into a re-usable action

* Commit actions.

* fix action

* remove checkout extraction
  • Loading branch information
tuncaytunc-zf authored Apr 19, 2023
1 parent f6b877c commit baa621a
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 150 deletions.
10 changes: 2 additions & 8 deletions .github/actions/publish-docker-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ inputs:
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/[email protected]

#####################
# Login to DockerHub
Expand All @@ -56,12 +55,7 @@ runs:
#####################
# Build JAR file
#####################
- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/setup-java
- name: Build Controlplane
shell: bash
run: |-
Expand Down
10 changes: 2 additions & 8 deletions .github/actions/run-deployment-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,15 @@ inputs:
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/[email protected]

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

- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/setup-java

- name: Build docker images
shell: bash
Expand Down
32 changes: 32 additions & 0 deletions .github/actions/setup-java/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

---
name: "Setup JDK 17"
description: "Setup JDK 17"
runs:
using: "composite"
steps:
- name: Setup JDK 17
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
26 changes: 6 additions & 20 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,8 @@ jobs:
needs: [ secret-presence ]
steps:
# Set-Up
- name: Checkout
uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: actions/[email protected]
- uses: ./.github/actions/setup-java
# Build
- name: Build Extensions
run: |-
Expand All @@ -104,8 +98,7 @@ jobs:
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/[email protected]
- uses: ./.github/actions/publish-docker-image
with:
rootDir: edc-controlplane/${{ matrix.name }}
Expand All @@ -128,8 +121,7 @@ jobs:
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/[email protected]
- uses: ./.github/actions/publish-docker-image
with:
rootDir: edc-dataplane/${{ matrix.name }}
Expand All @@ -149,15 +141,9 @@ jobs:
needs.secret-presence.outputs.GPG_PASSPHRASE && needs.secret-presence.outputs.GPG_PRIVATE_KEY && github.event_name != 'pull_request' && github.ref != 'refs/heads/releases'
steps:
# Set-Up
- name: Checkout
uses: actions/[email protected]
- uses: actions/[email protected]

- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/setup-java
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v5
with:
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/business-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,9 @@ jobs:
### Set-Up ###
##############
-
name: Checkout
uses: actions/[email protected]
-
name: Set-Up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
uses: ./.github/actions/setup-java
-
name: Cache ContainerD Image Layers
uses: actions/cache@v3
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/deployment-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ jobs:
deployment-test-memory:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/[email protected]
- uses: ./.github/actions/run-deployment-test
name: "Run deployment test using KinD and Helm"
with:
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/draft-new-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ jobs:
git config user.name "GitHub actions"
git config user.email [email protected]
-
name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
uses: ./.github/actions/setup-java
-
name: Bump version in gradle.properties
run: |-
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/helm-chart-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:

steps:
# fetch-depth: 0 is required to determine differences in chart(s)
- name: Checkout
uses: actions/checkout@v3
- uses: actions/[email protected]
with:
fetch-depth: 0

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/helm-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
### Set-Up ###
##############
-
name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ jobs:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/[email protected]
- uses: ./.github/actions/publish-docker-image
with:
rootDir: edc-controlplane/${{ matrix.name }}
Expand All @@ -74,8 +73,7 @@ jobs:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/[email protected]
- uses: ./.github/actions/publish-docker-image
with:
rootDir: edc-dataplane/${{ matrix.name }}
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/publish-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,9 @@ jobs:
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/[email protected]
-
name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
uses: ./.github/actions/setup-java

- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v5
Expand Down Expand Up @@ -96,7 +90,6 @@ jobs:
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
Expand Down Expand Up @@ -144,7 +137,6 @@ jobs:
run: |
echo "RELEASE_VERSION=${{ needs.release-version.outputs.RELEASE_VERSION }}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/[email protected]
with:
# 0 to fetch the full history due to upcoming merge of releases into main branch
Expand Down Expand Up @@ -177,12 +169,7 @@ jobs:
draft: false
prerelease: false
-
name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
uses: ./.github/actions/setup-java
-
name: Merge releases back into main and set new snapshot version
if: github.event.pull_request.base.ref == 'releases'
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ jobs:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/[email protected]
- uses: actions/[email protected]
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
Expand Down Expand Up @@ -72,8 +71,7 @@ jobs:
- edc-dataplane-azure-vault
- edc-dataplane-hashicorp-vault
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/[email protected]

## This step will fail if the docker images is not found
- name: "Check if image exists"
Expand Down
30 changes: 6 additions & 24 deletions .github/workflows/veracode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ jobs:
verify-formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: ./.github/actions/setup-java
- name: Verify proper formatting
run: ./gradlew spotlessCheck

Expand All @@ -51,14 +45,8 @@ jobs:
- edc-controlplane-postgresql-hashicorp-vault
steps:
# Set-Up
- name: Checkout
uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: actions/[email protected]
- uses: ./.github/actions/setup-java
# Build
- name: Build Controlplane
run: |-
Expand Down Expand Up @@ -95,14 +83,8 @@ jobs:
- edc-dataplane-hashicorp-vault
steps:
# Set-Up
- name: Checkout
uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: actions/[email protected]
- uses: ./.github/actions/setup-java
# Build
- name: Build Dataplane
run: |-
Expand Down
Loading

0 comments on commit baa621a

Please sign in to comment.