Skip to content

Commit 2c4b657

Browse files
authored
Merge pull request #1660 from Adyen/fix/java-format-in-ci
feat(ci): create in place formatting workflow for composable steps
2 parents ffc0959 + c43e3e1 commit 2c4b657

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

.github/actions/format/action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'Format Java Code'
2+
description: 'Runs mvn spotless:apply'
3+
inputs:
4+
path:
5+
description: 'Path to the java repository'
6+
required: true
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Set up JDK 11 for formatting
11+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v4.2.1
12+
with:
13+
java-version: '11'
14+
distribution: 'temurin'
15+
16+
- name: Cache Maven packages
17+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.0.2
18+
with:
19+
path: ~/.m2
20+
key: ${{ runner.os }}-m2-${{ hashFiles(format('{0}/**/pom.xml', inputs.path)) }}
21+
restore-keys: |
22+
${{ runner.os }}-m2-
23+
24+
- name: Run Spotless Apply
25+
run: mvn spotless:apply
26+
shell: bash
27+
working-directory: ${{ inputs.path }}

.github/workflows/format.yml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
name: Java Code Format
1+
name: Format and Commit Java Code
22

33
on:
44
workflow_dispatch:
5-
push:
6-
branches:
7-
- 'sdk-automation/*'
85

96
permissions:
107
contents: write
@@ -19,22 +16,10 @@ jobs:
1916
with:
2017
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
2118

22-
- name: Set up JDK
23-
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165
19+
- name: Format Java Code
20+
uses: ./.github/actions/format
2421
with:
25-
java-version: '20'
26-
distribution: 'adopt'
27-
28-
- name: Cache Maven packages
29-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
30-
with:
31-
path: ~/.m2
32-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
33-
restore-keys: |
34-
${{ runner.os }}-m2-
35-
36-
- name: Run Spotless Apply
37-
run: mvn spotless:apply
22+
path: .
3823

3924
- name: Commit and Push Changes
4025
env:

0 commit comments

Comments
 (0)