From c270c87cfb47b7ef3b75c3a2dc9455daad696b2e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 21 Oct 2024 22:28:08 +0000 Subject: [PATCH] Use `creyD/prettier_action@v4.3` for auto-apply of prettier in pull requests --- .github/workflows/prettier-pr.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/prettier-pr.yml b/.github/workflows/prettier-pr.yml index 051b1abd..fe0df964 100644 --- a/.github/workflows/prettier-pr.yml +++ b/.github/workflows/prettier-pr.yml @@ -2,18 +2,25 @@ name: Prettier on pull requests on: pull_request: + branches: + - main workflow_dispatch: jobs: prettier: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - # Need node to install prettier plugin(s) - - uses: actions/setup-node@v4 + - name: "Checkout repository's previous and current states" + uses: actions/checkout@v4 with: - node-version: 20 - - run: npm ci - - run: | - echo "Prettier-ing files" - npx prettier "src/**/*.{js,jsx}" --check + ref: ${{ github.head_ref }} + fetch-depth: 0 + persist-credentials: false + + - name: "Run prettier on the changed files" + uses: creyD/prettier_action@v4.3 # https://github.com/creyD/prettier_action/blob/v4.3/entrypoint.sh + with: + prettier_options: >- + --write + **/*.{js,jsx} + only_changed: true