Skip to content

Commit 609fd77

Browse files
authored
Merge pull request #706 from db-ui/feat-self-healing-dependabot-updates
feat: self healing dependabot updates
2 parents 666f5df + e4f7244 commit 609fd77

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
---
5+
name: Auto-Format with Stylelint and Prettier on PR for "self-healing" PRs
6+
7+
on:
8+
workflow_call:
9+
10+
jobs:
11+
format:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{github.event.pull_request.head.ref}}
18+
fetch-depth: 0
19+
20+
- name: Check if Stylelint or Prettier update PR
21+
id: check_pr
22+
run: |
23+
echo "PR title: ${{ github.event.pull_request.title }}"
24+
if [[ "${{ github.event.pull_request.title }}" =~ "bump stylelint from" ]]; then
25+
echo "Stylelint update detected."
26+
echo "stylelint_update=true" >> $GITHUB_ENV
27+
elif [[ "${{ github.event.pull_request.title }}" =~ "bump prettier from" ]]; then
28+
echo "Prettier update detected."
29+
echo "prettier_update=true" >> $GITHUB_ENV
30+
else
31+
echo "No Stylelint or prettier updates detected."
32+
fi
33+
34+
- name: Set up Node.js
35+
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version-file: ".nvmrc"
39+
40+
- name: Install dependencies
41+
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
42+
run: |
43+
npm ci
44+
45+
- name: Run Stylelint to format the code
46+
if: env.stylelint_update == 'true'
47+
run: |
48+
npx --no stylelint "**/*.*css" --fix
49+
50+
- name: Run Prettier to format the code
51+
if: env.prettier_update == 'true'
52+
run: |
53+
npx --no prettier . --write
54+
55+
- name: Commit changes if formatting is done
56+
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
57+
run: |
58+
git config --global user.name 'github-actions[bot]'
59+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
60+
echo 'COMMIT_MAIL=github-actions[bot]@users.noreply.github.com' >> .env
61+
62+
git add .
63+
git commit --all -m "refactor(test): auto-format codebase" || echo "No changes to commit"
64+
git push origin HEAD:${{ github.head_ref }} # Push back to the same PR branch

.github/workflows/pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
auto-merge:
2020
uses: ./.github/workflows/99-auto-merge.yml
2121

22+
self-healing-dependabot-updates:
23+
uses: ./.github/workflows/99-self-healing-dependabot-updates.yml
24+
2225
codeql:
2326
uses: ./.github/workflows/99-codeql-analysis.yml
2427

0 commit comments

Comments
 (0)