Skip to content

Commit 672b7f1

Browse files
committed
add github action to format code
1 parent f562f6d commit 672b7f1

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

.github/workflows/pr-format.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Format PR Code
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- ready_for_review
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
format:
16+
if: github.event.pull_request.head.repo.full_name == github.repository
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout PR branch
21+
uses: actions/checkout@v4
22+
with:
23+
ref: ${{ github.event.pull_request.head.ref }}
24+
fetch-depth: 0
25+
26+
- name: Set up Java 21
27+
uses: actions/setup-java@v4
28+
with:
29+
distribution: temurin
30+
java-version: "21"
31+
cache: gradle
32+
33+
- name: Set up Gradle
34+
uses: gradle/actions/setup-gradle@v4
35+
36+
- name: Format Java sources
37+
run: ./gradlew formatJava
38+
39+
- name: Commit formatted changes
40+
run: |
41+
if git diff --quiet; then
42+
echo "No formatting changes detected"
43+
exit 0
44+
fi
45+
git config user.name "github-actions[bot]"
46+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
47+
git add -A
48+
git commit -m "Apply Palantir Java Format"
49+
git push

0 commit comments

Comments
 (0)