-
Notifications
You must be signed in to change notification settings - Fork 101
40 lines (38 loc) · 1.38 KB
/
formatting.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Format code
on:
pull_request:
branches: [ master ]
paths-ignore:
- '**.md'
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Check code compliance to google java format standards
uses: gradle/gradle-build-action@v2
with:
arguments: verGJF
- name: Comment PR if code does not comply to Google Java style guide
if: ${{ failure() }}
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "This contribution does not follow the conventions set by the [Google Java style guide](https://google.github.io/styleguide/javaguide.html). Please run the following command line at the root of the project to fix formatting errors: ```./gradlew goJF```."
})