-
Notifications
You must be signed in to change notification settings - Fork 2
50 lines (42 loc) · 1.46 KB
/
SwiftLint.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
name: SwiftLint on Changed Files
on: push
jobs:
swiftlint:
name: Run SwiftLint
runs-on: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all history so that we can get the proper list of changed files
- name: Get changed files
id: changes
# Set outputs using the command.
run: |
echo "::set-output name=all::$(git diff --name-only --diff-filter=AM ${{ github.event.before }} ${{ github.sha }} | xargs)"
- name: Install SwiftLint
run: brew install swiftlint
# - name: List all changed files
# id: files
# uses: jitterbit/get-changed-files@v1
# with:
# format: space-delimited
- name: Run SwiftLint on changed files
run: |
# Extract changed files and filter for Swift files
FILES="${{ steps.changes.outputs.all }}"
SWIFT_FILES=$(echo "$FILES" | grep -E '\.(swift)$' | xargs)
echo $SWIFT_FILES
# Run SwiftLint on each changed Swift file
# If no Swift files changed, skip the step
if [ -z "$SWIFT_FILES" ]; then
echo "No Swift files to lint."
else
echo "Linting changed Swift files..."
swiftlint --config dydx/.swiftlint.yml --fix --format lint -- $SWIFT_FILES
fi
CHANGED=`git diff --quiet HEAD > /dev/null 2>&1`
if [ $CHANGED -ne 0 ]; then
git commit -am "SwiftLint"
git push
fi