Skip to content

Commit 2583afc

Browse files
committed
Only run the pre-commit hook on changed files
1 parent 163ebfe commit 2583afc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

.github/workflows/pre-commit.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v3
13+
- uses: technote-space/get-diff-action@v4.0.1
14+
with:
15+
PATTERNS: |
16+
+src/**/*.hs
1317
1418
- uses: ./.github/actions/setup-build
1519
with:
@@ -20,10 +24,12 @@ jobs:
2024
run: |
2125
cabal install stylish-haskell
2226
echo "${HOME}/.cabal/bin" >> $GITHUB_PATH
27+
if: env.GIT_DIFF
2328

2429
- name: "Check stylish-haskell is available"
2530
run: |
2631
echo $(which stylish-haskell)
32+
if: env.GIT_DIFF
2733

2834
- name: Compiled deps cache
2935
id: stylish-haskell-compiled-cache
@@ -37,6 +43,11 @@ jobs:
3743
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-${{ env.INDEX_STATE }}-
3844
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-${{ inputs.ghc }}-
3945
${{ inputs.cache-prefix }}${{ env.cache-name }}-${{ inputs.os }}-
46+
if: env.GIT_DIFF
4047

4148
- uses: actions/setup-python@v4
49+
if: env.GIT_DIFF
4250
- uses: pre-commit/action@v3.0.0
51+
with:
52+
extra_args: --files env.GIT_DIFF
53+
if: env.GIT_DIFF

0 commit comments

Comments
 (0)