From dcf9ba9d807705e81c8359a4b799f1e7bf00b1c8 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Sat, 5 Aug 2023 14:16:17 +0800 Subject: [PATCH] feat(ci): auto format code --- .github/workflows/format.yml | 32 ++++++++++++++++++++++++++++++++ package.json | 4 +++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..b612a7023 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,32 @@ +name: Format + +on: + push: + branches: [main] + +jobs: + format: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v3 + - uses: pnpm/action-setup@v2.2.4 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install dependencies + run: pnpm install + + - name: Format + run: pnpm run format + + - name: Add, Commit and Push + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "style: format code with prettier" diff --git a/package.json b/package.json index 194d36633..1232a25ab 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "url": "https://www.nn.ci" }, "description": "The front end of Alist V3", + "packageManager": "pnpm@8.6.10", "repository": { "type": "git", "url": "git+https://github.com/alist-org/alist-web.git" @@ -28,7 +29,8 @@ "dev": "vite", "build": "vite build", "serve": "vite preview", - "prepare": "husky install" + "prepare": "husky install", + "format": "prettier --ignore-path .gitignore -w \"src/**/*.{js,ts,json,css,tsx,jsx}\"" }, "license": "MIT", "devDependencies": {