Skip to content

Commit 4b8a317

Browse files
feat: use git diff action
1 parent 721c3bf commit 4b8a317

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,31 @@ jobs:
1616
- uses: actions/checkout@v2
1717
with:
1818
fetch-depth: 3
19+
- uses: technote-space/get-diff-action@v1
20+
id: git-diff
21+
with:
22+
PREFIX_FILTER: |
23+
src/
24+
__tests__/
25+
SUFFIX_FILTER: .ts
1926
- name: Get Yarn Cache Directory
2027
id: yarn-cache
2128
run: echo "::set-output name=dir::$(yarn cache dir)"
29+
if: steps.git-diff.outputs.diff
2230
- name: Cache node dependencies
2331
uses: actions/cache@v1
2432
with:
2533
path: ${{ steps.yarn-cache.outputs.dir }}
2634
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
2735
restore-keys: |
2836
${{ runner.os }}-yarn-
37+
if: steps.git-diff.outputs.diff
2938
- name: Install Package dependencies
3039
run: yarn install
40+
if: steps.git-diff.outputs.diff
3141
- name: Check code style
32-
run: yarn lint
42+
run: yarn eslint ${{ steps.git-diff.outputs.diff }}
43+
if: steps.git-diff.outputs.diff
3344
- uses: 8398a7/action-slack@v1
3445
with:
3546
type: failure
@@ -49,30 +60,42 @@ jobs:
4960
- uses: actions/checkout@v2
5061
with:
5162
fetch-depth: 3
63+
- uses: technote-space/get-diff-action@v1
64+
id: git-diff
65+
with:
66+
PREFIX_FILTER: |
67+
src/
68+
__tests__/
69+
SUFFIX_FILTER: .ts
5270
- name: Setup node
5371
uses: actions/setup-node@v1
5472
with:
5573
node-version: ${{ matrix.node }}
74+
if: steps.git-diff.outputs.diff || github.event_name == 'push'
5675
- name: Get Yarn Cache Directory
5776
id: yarn-cache
5877
run: echo "::set-output name=dir::$(yarn cache dir)"
78+
if: steps.git-diff.outputs.diff || github.event_name == 'push'
5979
- name: Cache node dependencies
6080
uses: actions/cache@v1
6181
with:
6282
path: ${{ steps.yarn-cache.outputs.dir }}
6383
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
6484
restore-keys: |
6585
${{ runner.os }}-yarn-
86+
if: steps.git-diff.outputs.diff || github.event_name == 'push'
6687
- name: Install Package dependencies
6788
run: yarn install
89+
if: steps.git-diff.outputs.diff || github.event_name == 'push'
6890
- name: Run tests
6991
run: yarn cover
92+
if: steps.git-diff.outputs.diff || github.event_name == 'push'
7093
- name: Codecov
7194
run: curl -s https://codecov.io/bash | bash -s -- -t $CODECOV_TOKEN -f $COVERAGE_FILE
7295
env:
7396
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7497
COVERAGE_FILE: ./coverage/lcov.info
75-
if: matrix.node == '12'
98+
if: matrix.node == '12' && (steps.git-diff.outputs.diff || github.event_name == 'push')
7699
- uses: 8398a7/action-slack@v1
77100
with:
78101
type: failure

0 commit comments

Comments
 (0)