-
Notifications
You must be signed in to change notification settings - Fork 15
56 lines (47 loc) · 1.49 KB
/
prettier.yml
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
51
52
53
54
55
56
name: Prettier Format and Commit
on:
push:
branches:
- main
- 'refs/heads/*'
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Install dependencies
run: npm install
- name: Pull latest changes
run: git pull
- name: Run Prettier
run: npx prettier --write .
- name: Commit changes
id: commit
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
if git diff-index --quiet HEAD; then
echo "No changes to commit."
echo "changes_committed=false" >> $GITHUB_ENV
else
git commit -m "chore: format code with Prettier"
echo "changes_committed=true" >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Pull Request
if: env.changes_committed == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: format code with Prettier'
branch: prettier-fix
title: 'chore: format code with Prettier'
body: 'This PR formats the code with Prettier.'
labels: prettier