-
-
Notifications
You must be signed in to change notification settings - Fork 236
47 lines (41 loc) · 1.14 KB
/
fmt.yaml
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
name: fmt
on:
push:
branches:
- "*"
workflow_dispatch:
permissions:
contents: read
jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
- name: install ruff
run: pip install ruff
- name: Format code
run: pdm fmt && pdm lint --fix
- name: Check for changes
id: check_changes
run: |
if [ -n "$(git diff)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
continue-on-error: true
# Optionally, customize the user name and commit message, and can add an email as well such as Github Actions' email
- name: Set up Git and Commit Changes
run: |
if [ "${{ steps.check_changes.outputs.changed }}" == "true" ]; then
git config --local user.name "Formatter [BOT]"
git add .
git commit -m "Auto-format code 🧹🌟🤖"
git push
fi