-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DX: set
PRETTIER_LEGACY_CLI
when Prettier v4 alpha (#41)
* FIX: checkout branch
- Loading branch information
Showing
1 changed file
with
20 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,23 +69,31 @@ jobs: | |
- if: needs.determine-hooks.outputs.skipped-hooks != 'ALL' | ||
name: Run pre-commit hooks that don't work on pre-commit.ci | ||
run: |- | ||
for hook in ${{ needs.determine-hooks.outputs.skipped-hooks }}; do | ||
export skipped_hooks='${{ needs.determine-hooks.outputs.skipped-hooks }}' | ||
if [[ $skipped_hooks == *"prettier"* ]]; then | ||
export PRETTIER_LEGACY_CLI=1 | ||
fi | ||
for hook in $skipped_hooks; do | ||
pre-commit run $hook --all-files --color always | ||
done | ||
- id: diff | ||
if: always() | ||
name: Determine changed files | ||
run: | | ||
some_file_in_root=$(git ls-files --directory | grep -E '^[^/]+$' | head -n1) | ||
diff_files="$some_file_in_root $(git diff --name-only)" | ||
delimiter="$(openssl rand -hex 8)" | ||
echo "diff<<${delimiter}" >> $GITHUB_OUTPUT | ||
git diff --name-only | tee -a $GITHUB_OUTPUT | ||
for file in $diff_files; do | ||
echo "$file" | tee -a $GITHUB_OUTPUT | ||
done | ||
echo "${delimiter}" >> $GITHUB_OUTPUT | ||
echo | ||
git diff --color | ||
# https://github.com/actions/upload-artifact/issues/174#issuecomment-934330651 | ||
shell: bash | ||
- if: always() && steps.diff.outputs.diff != '' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
if-no-files-found: error | ||
name: pre-commit-changes | ||
path: ${{ steps.diff.outputs.diff }} | ||
|
||
|
@@ -109,14 +117,20 @@ jobs: | |
if: always() | ||
name: Determine changed files | ||
run: | | ||
some_file_in_root=$(git ls-files --directory | grep -E '^[^/]+$' | head -n1) | ||
diff_files="$some_file_in_root $(git diff --name-only)" | ||
delimiter="$(openssl rand -hex 8)" | ||
echo "diff<<${delimiter}" >> $GITHUB_OUTPUT | ||
git diff --name-only | tee -a $GITHUB_OUTPUT | ||
for file in $diff_files; do | ||
echo "$file" | tee -a $GITHUB_OUTPUT | ||
done | ||
echo "${delimiter}" >> $GITHUB_OUTPUT | ||
# https://github.com/actions/upload-artifact/issues/174#issuecomment-934330651 | ||
shell: bash | ||
- if: always() && steps.diff.outputs.diff != '' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
if-no-files-found: error | ||
name: pre-commit-changes | ||
path: ${{ steps.diff.outputs.diff }} | ||
|
||
|
@@ -147,6 +161,7 @@ jobs: | |
git remote set-url origin https://x-access-token:${{ secrets.token }}@github.com/${{ github.repository }} | ||
git config user.name "GitHub" | ||
git config user.email "[email protected]" | ||
git checkout -b ${{ github.head_ref }} | ||
git add -A | ||
git commit -m "MAINT: implement updates from pre-commit hooks" | ||
git config pull.rebase true | ||
|