From 47fff37fe70c7180ec1708a56f8e65f420fc97f0 Mon Sep 17 00:00:00 2001 From: Guus van der Meer Date: Mon, 25 Dec 2023 20:59:59 +0100 Subject: [PATCH] Added action that forces prettier to be run --- .github/workflows/prettier.yml | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/prettier.yml diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 00000000..8c1fd0dc --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,35 @@ +name: Prettier + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + prettier: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: npm ci + + - name: Run Prettier + run: npm run prettier + + - name: Check for changes + id: changes + run: | + git diff --name-only --exit-code HEAD^ HEAD | grep -vE 'package-lock.json' + + - name: Fail if changes found + run: | + if [ -n "${{ steps.changes.outputs.stdout }}" ]; then + echo "There are changes after running Prettier. Please run Prettier locally and commit the changes."; + exit 1; + fi