-
Notifications
You must be signed in to change notification settings - Fork 6
31 lines (26 loc) · 1.1 KB
/
ktlint.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
name: Kotlin-Linter
on:
pull_request:
jobs:
ktlint:
runs-on: macos-latest
steps:
- name: Get changed files
id: changes
run: |
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
RESPONSE=$(curl -s -X GET -G $URL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}')
CHANGED_KOTLIN_FILES=$(echo $RESPONSE | jq -r '.[] | .filename' | grep -E "\.kt$" | tr \'\\n\' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')
echo "Changed Kotlin files: ${CHANGED_KOTLIN_FILES}"
echo "changed_kotlin_files=${CHANGED_KOTLIN_FILES}" >> $GITHUB_ENV
- name: "checkout"
if: env.changed_kotlin_files != ''
uses: actions/checkout@v4
- name: Install ktlint
if: env.changed_kotlin_files != ''
run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.50.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
- name: run ktlint
if: env.changed_kotlin_files != ''
run: |
ktlint . '!**/build/**'