Skip to content

Commit 05a80fc

Browse files
committed
ci: add diff whitespace check
1 parent 6322a4d commit 05a80fc

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ jobs:
1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
16+
with:
17+
fetch-depth: 1
18+
19+
- name: Run git diff --check
20+
shell: bash
21+
env:
22+
EVENT_NAME: ${{ github.event_name }}
23+
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
24+
PUSH_BEFORE_SHA: ${{ github.event.before }}
25+
GITHUB_SHA: ${{ github.sha }}
26+
run: |
27+
if [ "$EVENT_NAME" = "pull_request" ]; then
28+
git fetch --no-tags --depth=1 origin "$PR_BASE_SHA"
29+
git diff --check "$PR_BASE_SHA" HEAD
30+
elif [ "$PUSH_BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then
31+
git diff-tree --check --no-commit-id --root -r "$GITHUB_SHA"
32+
else
33+
git fetch --no-tags --depth=1 origin "$PUSH_BEFORE_SHA"
34+
git diff --check "$PUSH_BEFORE_SHA" HEAD
35+
fi
1636
1737
- name: Run markdownlint-cli2
1838
uses: DavidAnson/markdownlint-cli2-action@ded1f9488f68a970bc66ea5619e13e9b52e601cd # v23

0 commit comments

Comments
 (0)