From 4edd468ace1b07663702cb6f4e9f5850e94b543c Mon Sep 17 00:00:00 2001 From: RhenCloud Date: Mon, 3 Aug 2026 00:44:01 +0800 Subject: [PATCH] ci: add workflow to auto-fix lint and formatting --- .github/workflows/lint-format.yml | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/lint-format.yml diff --git a/.github/workflows/lint-format.yml b/.github/workflows/lint-format.yml new file mode 100644 index 0000000..2b95f07 --- /dev/null +++ b/.github/workflows/lint-format.yml @@ -0,0 +1,60 @@ +name: lint-format + +on: + push: + branches: [main] + +permissions: + contents: write + +concurrency: + group: lint-format-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-and-fix: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: oven-sh/setup-bun@v2 + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Run checks + id: check + continue-on-error: true + run: | + bun run lint + bun run format:check + bun run lint:md + + - name: Apply fixes + run: | + bunx eslint src/ --fix + bunx prettier --write . + bunx markdownlint "**/*.md" --ignore node_modules --ignore dist --fix + + - name: Commit and push fixes + if: steps.check.outcome == 'failure' + run: | + if [ -z "$(git status --porcelain)" ]; then + echo "No changes to commit" + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config commit.gpgsign false + git add -A + git commit -m "chore: auto-fix lint & formatting [skip ci]" + git push + + - name: Verify fixes + run: | + bun run lint + bun run format:check + bun run lint:md