aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/lint.yml
diff options
context:
space:
mode:
authorNtskwK <natsukawa247@outlook.com>2026-01-16 09:13:38 +0800
committerNtskwK <natsukawa247@outlook.com>2026-01-16 09:13:38 +0800
commit73e83b4cb5b1adcd0463fc32d558d71a391b9264 (patch)
treef09b18e3b99706aa3762fb7deb17241fed2c8801 /.github/workflows/lint.yml
parent9688bbd2f1ac5acb4b170dcf4d4908a548746cba (diff)
downloadDropOut-73e83b4cb5b1adcd0463fc32d558d71a391b9264.tar.gz
DropOut-73e83b4cb5b1adcd0463fc32d558d71a391b9264.zip
chore: add UI linter workflow with oxlint and oxfmt
Diffstat (limited to '.github/workflows/lint.yml')
-rw-r--r--.github/workflows/lint.yml93
1 files changed, 93 insertions, 0 deletions
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 0000000..c8d1b27
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,93 @@
+name: UI Linter
+
+on:
+ workflow_run:
+ workflows: ["UI Checker"]
+ types:
+ - completed
+ workflow_dispatch:
+ inputs:
+ commit_message:
+ description: "Commit Message"
+ type: string
+ required: false
+
+jobs:
+ check:
+ if: |
+ (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') ||
+ github.event_name == 'workflow_dispatch'
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check if it is a direct push
+ id: check_push
+ run: |
+ if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
+ if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then
+ echo "PR detected. Exiting."
+ echo "is_pr=True" >> $GITHUB_OUTPUT
+ else
+ echo "Direct push or other event detected. Proceeding..."
+ echo "is_pr=False" >> $GITHUB_OUTPUT
+ fi
+ else
+ echo "Manual trigger detected. Proceeding..."
+ echo "is_pr=False" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Checkout repository
+ if: steps.check_push.outputs.is_pr != 'True'
+ uses: actions/checkout@v6
+ with:
+ show-progress: false
+ persist-credentials: false
+
+ - name: Install pnpm
+ if: steps.check_push.outputs.is_pr != 'True'
+ uses: pnpm/action-setup@v4
+ with:
+ version: 9
+ run_install: true
+ package_json_file: ui/package.json
+
+ - name: Install Node.js
+ if: steps.check_push.outputs.is_pr != 'True'
+ uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: "pnpm"
+ cache-dependency-path: ui/pnpm-lock.yaml
+
+ - run: pnpm format
+ working-directory: ui
+
+ - run: pnpm lint:fix
+ working-directory: ui
+
+ - name: Commit changes
+ id: commit_changes
+ if: steps.check_push.outputs.is_pr != 'True'
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+
+ git add .
+
+ if git diff-index --quiet HEAD --; then
+ echo "No changes to commit"
+ else
+ commit_msg="${{ github.event.inputs.commit_message }}"
+ if [ -z "$commit_msg" ]; then
+ commit_msg="chore: Auto Templates Optimization"
+ fi
+ git commit -m "$commit_msg" -m "Triggered by ${{github.sha}}" -m "[skip changelog]"
+ git pull origin $(git rev-parse --abbrev-ref HEAD) --unshallow --rebase
+ echo "have_commits=True" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Push changes
+ if: steps.check_push.outputs.is_pr != 'True' && steps.commit_changes.outputs.have_commits == 'True' && github.repository_owner == 'MAA1999'
+ uses: ad-m/github-push-action@master
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ branch: ${{ github.ref }}