-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (63 loc) · 1.9 KB
/
code-format.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: 🎀 Code Format (Verification)
on:
push:
branches:
- main
- develop
pull_request:
jobs:
code-format:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/create-github-app-token@v1
id: fleek-platform-bot-token
with:
app-id: ${{ secrets.FLEEK_PLATFORM_BOT_APP_ID }}
private-key: ${{ secrets.FLEEK_PLATFORM_BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref }}
token: ${{ steps.fleek-platform-bot-token.outputs.token }}
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 7.32.4
run_install: false
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: |
pnpm i
- name: Code format check
id: fmt_check
continue-on-error: true
run: |
if ! pnpm format:check; then
echo "exit_code=1" >> "$GITHUB_OUTPUT"
fi
- name: Auto-format
if: steps.fmt_check.outputs.exit_code != '0' && github.event_name == 'pull_request'
run: |
pnpm format:unsafe
- name: Commit formatted
if: steps.fmt_check.outputs.exit_code != '0' && github.event_name == 'pull_request'
run: |
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
if [[ -n "$(git status --porcelain)" ]]; then
git add .
if git commit -m "chore: 🤖 code format" --no-verify; then
git push
else
echo "🦖 Skipped! No changes to commit..."
fi
else
echo "🦖 Skipped! No changes found."
fi