-
Notifications
You must be signed in to change notification settings - Fork 1
65 lines (55 loc) · 1.64 KB
/
lint.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Lint
on:
pull_request:
paths:
- ".github/workflows/lint.yml"
- "**.swift"
- '.swiftlint.yml'
- '.swiftformat'
jobs:
format:
name: SwiftFormat
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Print current branch name
run: |
echo ${{ github.ref_name }}
git log -1
- run: |
echo ${{ github.event.pull_request.head.sha }}
echo ${{ github.event.pull_request.base.sha }}
- name: Get list changed files
id: changed-files
uses: tj-actions/changed-files@v17
with:
sha: ${{ github.event.pull_request.head.sha }}
base_sha: ${{ github.event.pull_request.base.sha }}
separator: ","
files: |
**/*.swift
- name: Install SwiftFormat
run: brew install swiftformat
- name: Format Swift code
run: |
string='${{ steps.changed-files.outputs.all_changed_files }}'
IFS=, read -r -a files <<<"$string"
swiftformat --verbose "${files[@]}" --config .swiftformat
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply SwiftFormat changes
lint:
name: SwiftLint
runs-on: ubuntu-latest
needs: format
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: SwiftLint
uses: norio-nomura/[email protected]
env:
DIFF_BASE: ${{ github.base_ref }} # only files changed in the PR