-
Notifications
You must be signed in to change notification settings - Fork 19
50 lines (46 loc) · 1.33 KB
/
auto-format.yml
File metadata and controls
50 lines (46 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Auto-fix formatting of source code
on:
push:
branches:
- main
jobs:
fix_formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install packages
run: uv sync
- name: Auto-fix Python formatting
run: |
uv run ruff format
uv run ruff check --fix
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "npm"
- name: Install Prettier
run: npm ci --install-links=false
- name: Auto-fix code formatting (Prettier)
run: npx prettier --write .
- name: Commit changes
id: commit
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "actions@github.com"
git add .
if git diff --cached --quiet; then
echo "No formatting changes to commit."
else
git commit -m "✨ Auto-fix formatting"
echo "formatted=true" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: ${{ steps.commit.outputs.formatted == 'true' }}
run: git push origin HEAD