Skip to content

Code Formatting

Code Formatting #13

Workflow file for this run

name: Code Formatting
on:
workflow_call:
workflow_dispatch:
jobs:
format:
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Bei PRs checkt GitHub automatisch den PR-Branch aus
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Setup pnpm
uses: pnpm/action-setup@v4.1.0
with:
version: 9
- name: Install dependencies
run: pnpm install
- name: Run Prettier
run: pnpm prettier --write .
- name: Commit Changes
run: |
if [[ `git status --porcelain` ]]; then
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add .
git commit -m "chore(format): run Prettier to format codebase
- Applied Prettier formatting to ensure consistent code style"
else
echo "No changes to commit."
fi
- name: Pull remote changes (rebase)
if: success()
run: git pull --rebase origin main
- name: Push Changes
if: success() # Nur ausführen, wenn die vorherigen Schritte erfolgreich sind
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: git push origin HEAD