-
Notifications
You must be signed in to change notification settings - Fork 5
51 lines (43 loc) · 1.22 KB
/
format-code.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
name: Format Code
on:
pull_request:
branches:
- main
- production
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
format:
runs-on: ubuntu-latest
name: Format Files
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: "pnpm"
- run: pnpm i --no-frozen-lockfile
- name: Prettier
run: pnpm run format
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: stefanzweifel/git-auto-commit-action@v4
id: format-files
with:
commit_message: "chore(style): format files"
skip_checkout: true
branch: ${{ github.head_ref }}
create_branch: false
# Create PR with formatted files if changes were detected
- name: Push changes to PR branch
if: steps.format-files.outputs.changes_detected == 'true'
run: |
git push origin ${{ github.head_ref }}