mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
ci: add workflow to auto-fix lint and formatting
This commit is contained in:
parent
1fc702ceb4
commit
4edd468ace
1 changed files with 60 additions and 0 deletions
60
.github/workflows/lint-format.yml
vendored
Normal file
60
.github/workflows/lint-format.yml
vendored
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue