File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -21,16 +21,24 @@ jobs:
2121 runs-on : ubuntu-latest
2222 steps :
2323 - uses : actions/checkout@v1
24+ // Simple usage
2425 - name : GitHub Action for SwiftLint
2526 uses : norio-nomura/action-swiftlint@3.2.1
27+ // With custom argument
2628 - name : GitHub Action for SwiftLint with --strict
2729 uses : norio-nomura/action-swiftlint@3.2.1
2830 with :
2931 args : --strict
32+ // Only checks files changed in the PR
33+ - name : Fetch base ref
34+ run : |
35+ git fetch --prune --no-tags --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/heads/${{ github.base_ref }}
3036 - name : GitHub Action for SwiftLint (Only files changed in the PR)
3137 uses : norio-nomura/action-swiftlint@3.2.1
3238 env :
3339 DIFF_BASE : ${{ github.base_ref }}
40+ DIFF_HEAD : HEAD
41+ // Runs on different workspace
3442 - name : GitHub Action for SwiftLint (Different working directory)
3543 uses : norio-nomura/action-swiftlint@3.2.1
3644 env :
Original file line number Diff line number Diff line change 2020 cd ${WORKING_DIRECTORY}
2121fi
2222
23- if ! ${DIFF_BASE+false} ;
24- then
23+ if [ -n " $DIFF_BASE " ] && [ -n " $DIFF_HEAD " ]; then
24+ changedFiles=$( git --no-pager diff --name-only --relative $DIFF_HEAD $DIFF_BASE -- ' *.swift' )
25+
26+ if [ -z " $changedFiles " ]
27+ then
28+ echo " No Swift file changed"
29+ exit
30+ fi
31+ elif [ -n " $DIFF_BASE " ]; then
2532 changedFiles=$( git --no-pager diff --name-only --relative FETCH_HEAD $( git merge-base FETCH_HEAD $DIFF_BASE ) -- ' *.swift' )
2633
2734 if [ -z " $changedFiles " ]
You can’t perform that action at this time.
0 commit comments