Skip to content

feat: self healing dependabot updates #706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/99-self-healing-dependabot-updates.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading