Skip to content

Commit ab3ec64

Browse files
authored
Merge pull request #1170 from db-ui/feat-self-healing-dependabot-updates
feat: self healing dependabot updates
2 parents 7711fbb + fb62672 commit ab3ec64

File tree

2 files changed

+63
-0
lines changed

2 files changed

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

18+
self-healing-dependabot-updates:
19+
uses: ./.github/workflows/99-self-healing-dependabot-updates.yml
20+
1821
codeql:
1922
uses: ./.github/workflows/99-codeql-analysis.yml
2023

0 commit comments

Comments
 (0)