Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d70630f

Browse files
ci(pre-commit): Add label if manual fixes are required
1 parent d673d26 commit d70630f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

‎.github/workflows/pre-commit.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
6666

6767
- name: Run pre-commit hooks in changed files
68+
id: pre-commit
6869
run: pre-commit run --color=always --show-diff-on-failure --files ${{ steps.changed-files.outputs.all_changed_files }}
6970

7071
- name: Save pre-commit cache
@@ -82,3 +83,18 @@ jobs:
8283
if: ${{ always() && github.event_name == 'pull_request' }}
8384
with:
8485
msg: "ci(pre-commit): Apply automatic fixes"
86+
87+
- name: Add label if no commits are pending
88+
if: ${{ failure() && steps.pre-commit.outcome == 'failure' && steps.pre-commit.outputs.pending_commit == '0' && github.event_name == 'pull_request' }}
89+
run: |
90+
gh pr edit ${{ github.event.number }} --add-label 'Status: Pre-commit fixes required ⚠️'
91+
env:
92+
GH_TOKEN: ${{ github.token }}
93+
94+
- name: Remove label if everything was fixed
95+
if: ${{ success() && github.event_name == 'pull_request' }}
96+
run: |
97+
gh pr edit ${{ github.event.number }} --remove-label 'Status: Pre-commit fixes required ⚠️'
98+
env:
99+
GH_TOKEN: ${{ github.token }}
100+

‎.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,20 @@ repos:
108108
- id: vale
109109
language_version: "1.23.2"
110110
types_or: [markdown, rst]
111+
112+
# Always leave this last to ensure that all hooks have already run
113+
- repo: local
114+
hooks:
115+
- id: git-diff
116+
name: git diff
117+
entry: |
118+
bash -c '
119+
if [ "$CI" = "true" ]; then
120+
if git diff --exit-code; then
121+
echo "pending_commit=0" >> $GITHUB_OUTPUT
122+
else
123+
echo "pending_commit=1" >> $GITHUB_OUTPUT
124+
fi
125+
fi
126+
'
127+
language: system

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /