-
Notifications
You must be signed in to change notification settings - Fork 127
47 lines (41 loc) · 1.29 KB
/
Copy pathcode_style.yml
File metadata and controls
47 lines (41 loc) · 1.29 KB
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
41
42
43
44
45
46
47
name: Check code style
on:
push:
branches:
- main
- feature/ci_setup
pull_request:
paths:
- '.github/workflows/code_style.yml'
- '**/*.kt'
- '**/*.kts'
jobs:
check-code-style:
runs-on: ubuntu-latest
env:
BRANCH_REF: ${{ github.event_name == 'push' && github.ref || github.event.pull_request.head.ref }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
- name: Format code style
run: |
./gradlew ktlintFormat
- name: Commit files changed by ktlintFormat
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git add .
git diff --quiet && git diff --staged --quiet || git commit -m "Apply ktlint formatting"
- name: Check code style
shell: bash
run: ./gradlew ktlintCheck
- name: Pull latest changes
run: git pull --rebase origin ${BRANCH_REF}
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.event_name == 'push' && github.ref || github.event.pull_request.head.ref }}