CI: add a prettier GitHub action to format code automatically (#988)

* CI: add a prettier GitHub action to format code automatically

* improve GitHub Action config and format some files

* Apply formatting changes

* CI: make the prettier action a standalone action

* Apply formatting changes

* CI: add push as new trigger event

Co-authored-by: Mark-Fenng <Mark-Fenng@users.noreply.github.com>
This commit is contained in:
Yun Feng
2026-04-01 12:00:00 +08:00
committed by GitHub
parent c94b5783c4
commit f878cc032d
22 changed files with 109 additions and 54 deletions

View File

@@ -1,6 +1,6 @@
name: Eslint Check
on: [pull_request]
on: [pull_request, push]
jobs:
eslint_check_upload:

26
.github/workflows/prettier.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Prettier
on: [pull_request, push]
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: Install Dependencies
run: yarn
- name: Prettify code
run: yarn prettier --write '**/*.{ts,md}'
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply formatting changes
branch: ${{ github.head_ref }}