File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ concurrency:
13
13
cancel-in-progress : true
14
14
15
15
permissions :
16
- contents : write
17
- pull-requests : read
16
+ contents : read
17
+ pull-requests : write
18
18
19
19
jobs :
20
20
lint :
34
34
- name : Remove Label
35
35
if : contains(github.event.pull_request.labels.*.name, 'Re-trigger Pre-commit Hooks')
36
36
run : gh pr edit ${{ github.event.number }} --remove-label 'Re-trigger Pre-commit Hooks'
37
+ continue-on-error : true
37
38
env :
38
39
GH_TOKEN : ${{ github.token }}
39
40
65
66
uses : tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
66
67
67
68
- name : Run pre-commit hooks in changed files
69
+ id : pre-commit
68
70
run : pre-commit run --color=always --show-diff-on-failure --files ${{ steps.changed-files.outputs.all_changed_files }}
69
71
70
72
- name : Save pre-commit cache
82
84
if : ${{ always() && github.event_name == 'pull_request' }}
83
85
with :
84
86
msg : " ci(pre-commit): Apply automatic fixes"
87
+
88
+ - name : Add label if no commits are pending
89
+ if : ${{ failure() && steps.pre-commit.outcome == 'failure' && steps.pre-commit.outputs.pending_commit == '0' && github.event_name == 'pull_request' }}
90
+ continue-on-error : true
91
+ run : |
92
+ gh pr edit ${{ github.event.number }} --add-label 'Status: Pre-commit fixes required ⚠️'
93
+ env :
94
+ GH_TOKEN : ${{ github.token }}
95
+
96
+ - name : Remove label if everything was fixed
97
+ if : ${{ success() && github.event_name == 'pull_request' }}
98
+ continue-on-error : true
99
+ run : |
100
+ gh pr edit ${{ github.event.number }} --remove-label 'Status: Pre-commit fixes required ⚠️'
101
+ env :
102
+ GH_TOKEN : ${{ github.token }}
103
+
Original file line number Diff line number Diff line change @@ -108,3 +108,20 @@ repos:
108
108
- id : vale
109
109
language_version : " 1.23.2"
110
110
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
You can’t perform that action at this time.
0 commit comments