Skip to content

Commit ccc0f48

Browse files
Refactor Java CI workflow for pull requests
1 parent 907edc2 commit ccc0f48

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
1+
# Java CI Build — runs on pull_request (executes PR code)
2+
# This job does not attempt to write comments/labels; keep write actions in pull_request_target workflows.
13
name: ⚙️ Java CI Build
24

35
on:
4-
push:
5-
branches: [ main, master ]
66
pull_request:
7-
branches: [ main, master ]
7+
types: [opened, reopened, synchronize]
88

99
permissions:
1010
contents: read
11+
pull-requests: read
1112

1213
jobs:
1314
build:
15+
name: Build and Test
1416
runs-on: ubuntu-latest
15-
1617
steps:
17-
- name: 📥 Checkout code
18+
- name: Checkout PR code
1819
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
1922

20-
- name: Set up JDK 17
23+
- name: Set up JDK 17
2124
uses: actions/setup-java@v4
2225
with:
23-
distribution: 'temurin'
2426
java-version: '17'
27+
distribution: 'temurin'
28+
29+
- name: Cache Maven local repository
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.m2/repository
33+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
34+
restore-keys: |
35+
${{ runner.os }}-maven-
2536
26-
- name: 🧱 Build with Maven
27-
run: mvn -B package --file pom.xml
37+
- name: Build (Maven)
38+
run: mvn -B -DskipTests=false package
2839

29-
- name: 🧪 Run tests
30-
run: mvn test
40+
- name: Run tests
41+
run: mvn test -B
3142

32-
- name: 📦 Upload build artifact
43+
- name: Upload build artifact (optional)
44+
if: success()
3345
uses: actions/upload-artifact@v4
3446
with:
35-
name: mycmd-artifact
47+
name: mycmd-build
3648
path: target/*.jar

0 commit comments

Comments
 (0)