From 705dce1374089e56269e24844b0138b544a69b3b Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Wed, 28 May 2025 11:10:58 +0200 Subject: [PATCH 1/2] feat: self healing dependabot updates for prettier and stylelint updates --- .github/workflows/pull-request.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a1b960ad3..e4b45b6ac 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -19,6 +19,9 @@ jobs: auto-merge: uses: ./.github/workflows/99-auto-merge.yml + self-healing-dependabot-updates: + uses: ./.github/workflows/99-self-healing-dependabot-updates.yml + codeql: uses: ./.github/workflows/99-codeql-analysis.yml From e4f72442a953aa0c366a612c3cb47d0dc57c5fa3 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Wed, 28 May 2025 11:11:43 +0200 Subject: [PATCH 2/2] Create 99-self-healing-dependabot-updates.yml --- .../99-self-healing-dependabot-updates.yml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/99-self-healing-dependabot-updates.yml diff --git a/.github/workflows/99-self-healing-dependabot-updates.yml b/.github/workflows/99-self-healing-dependabot-updates.yml new file mode 100644 index 000000000..690b33df2 --- /dev/null +++ b/.github/workflows/99-self-healing-dependabot-updates.yml @@ -0,0 +1,64 @@ +# SPDX-FileCopyrightText: 2025 DB Systel GmbH +# +# SPDX-License-Identifier: Apache-2.0 +--- +name: Auto-Format with Stylelint and Prettier on PR for "self-healing" PRs + +on: + workflow_call: + +jobs: + format: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{github.event.pull_request.head.ref}} + fetch-depth: 0 + + - name: Check if Stylelint or Prettier update PR + id: check_pr + run: | + echo "PR title: ${{ github.event.pull_request.title }}" + if [[ "${{ github.event.pull_request.title }}" =~ "bump stylelint from" ]]; then + echo "Stylelint update detected." + echo "stylelint_update=true" >> $GITHUB_ENV + elif [[ "${{ github.event.pull_request.title }}" =~ "bump prettier from" ]]; then + echo "Prettier update detected." + echo "prettier_update=true" >> $GITHUB_ENV + else + echo "No Stylelint or prettier updates detected." + fi + + - name: Set up Node.js + if: env.stylelint_update == 'true' || env.prettier_update == 'true' + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + + - name: Install dependencies + if: env.stylelint_update == 'true' || env.prettier_update == 'true' + run: | + npm ci + + - name: Run Stylelint to format the code + if: env.stylelint_update == 'true' + run: | + npx --no stylelint "**/*.*css" --fix + + - name: Run Prettier to format the code + if: env.prettier_update == 'true' + run: | + npx --no prettier . --write + + - name: Commit changes if formatting is done + if: env.stylelint_update == 'true' || env.prettier_update == 'true' + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + echo 'COMMIT_MAIL=github-actions[bot]@users.noreply.github.com' >> .env + + git add . + git commit --all -m "refactor(test): auto-format codebase" || echo "No changes to commit" + git push origin HEAD:${{ github.head_ref }} # Push back to the same PR branch