Skip to content

ci: remove ref option from prettier workflow checkout #1881

ci: remove ref option from prettier workflow checkout

ci: remove ref option from prettier workflow checkout #1881

Workflow file for this run

name: Prettify Code
on:
pull_request:
push:
branches:
- main
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch base branch
if: github.event_name == 'pull_request'
run: git fetch origin ${{ github.event.pull_request.base.ref }}
- name: Get changed files
id: changed-files
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
BASE_SHA="origin/${{ github.event.pull_request.base.ref }}"
else
BASE_SHA="${{ github.event.before }}"
fi
git diff --name-only --diff-filter=ACMR -z $BASE_SHA HEAD | \
grep -zE '\.(js|md)$' | \
xargs -0 -r echo > changed_files.txt
if [ -s changed_files.txt ]; then
echo "has_files=true" >> $GITHUB_OUTPUT
echo "Changed files:"
cat changed_files.txt
else
echo "has_files=false" >> $GITHUB_OUTPUT
fi
- name: Check code formatting
if: steps.changed-files.outputs.has_files == 'true'
uses: creyD/[email protected]
with:
prettier_version: 2.8.8
prettier_options: --check $(cat changed_files.txt)
dry_run: true