@@ -69,23 +69,31 @@ jobs:
69
69
- if : needs.determine-hooks.outputs.skipped-hooks != 'ALL'
70
70
name : Run pre-commit hooks that don't work on pre-commit.ci
71
71
run : |-
72
- for hook in ${{ needs.determine-hooks.outputs.skipped-hooks }}; do
72
+ export skipped_hooks='${{ needs.determine-hooks.outputs.skipped-hooks }}'
73
+ if [[ $skipped_hooks == *"prettier"* ]]; then
74
+ export PRETTIER_LEGACY_CLI=1
75
+ fi
76
+ for hook in $skipped_hooks; do
73
77
pre-commit run $hook --all-files --color always
74
78
done
75
79
- id : diff
76
80
if : always()
77
81
name : Determine changed files
78
82
run : |
83
+ some_file_in_root=$(git ls-files --directory | grep -E '^[^/]+$' | head -n1)
84
+ diff_files="$some_file_in_root $(git diff --name-only)"
79
85
delimiter="$(openssl rand -hex 8)"
80
86
echo "diff<<${delimiter}" >> $GITHUB_OUTPUT
81
- git diff --name-only | tee -a $GITHUB_OUTPUT
87
+ for file in $diff_files; do
88
+ echo "$file" | tee -a $GITHUB_OUTPUT
89
+ done
82
90
echo "${delimiter}" >> $GITHUB_OUTPUT
83
- echo
84
- git diff --color
91
+ # https://github.com/actions/upload-artifact/issues/174#issuecomment-934330651
85
92
shell : bash
86
93
- if : always() && steps.diff.outputs.diff != ''
87
94
uses : actions/upload-artifact@v3
88
95
with :
96
+ if-no-files-found : error
89
97
name : pre-commit-changes
90
98
path : ${{ steps.diff.outputs.diff }}
91
99
@@ -109,14 +117,20 @@ jobs:
109
117
if : always()
110
118
name : Determine changed files
111
119
run : |
120
+ some_file_in_root=$(git ls-files --directory | grep -E '^[^/]+$' | head -n1)
121
+ diff_files="$some_file_in_root $(git diff --name-only)"
112
122
delimiter="$(openssl rand -hex 8)"
113
123
echo "diff<<${delimiter}" >> $GITHUB_OUTPUT
114
- git diff --name-only | tee -a $GITHUB_OUTPUT
124
+ for file in $diff_files; do
125
+ echo "$file" | tee -a $GITHUB_OUTPUT
126
+ done
115
127
echo "${delimiter}" >> $GITHUB_OUTPUT
128
+ # https://github.com/actions/upload-artifact/issues/174#issuecomment-934330651
116
129
shell : bash
117
130
- if : always() && steps.diff.outputs.diff != ''
118
131
uses : actions/upload-artifact@v3
119
132
with :
133
+ if-no-files-found : error
120
134
name : pre-commit-changes
121
135
path : ${{ steps.diff.outputs.diff }}
122
136
@@ -147,6 +161,7 @@ jobs:
147
161
git remote set-url origin https://x-access-token:${{ secrets.token }}@github.com/${{ github.repository }}
148
162
git config user.name "GitHub"
149
163
git config user.email "[email protected] "
164
+ git checkout -b ${{ github.head_ref }}
150
165
git add -A
151
166
git commit -m "MAINT: implement updates from pre-commit hooks"
152
167
git config pull.rebase true
0 commit comments