From f228acdac6756db213ebced24daf95a92b63b5b9 Mon Sep 17 00:00:00 2001 From: v_guanglwen Date: Thu, 12 Jun 2025 15:46:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20eslint=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 35 -------------------------- .github/workflows/pr-lint-check.yml | 39 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 35 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pr-lint-check.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 01376cff..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: WeChat MiniProgram Demo CI/CD - -on: - pull_request: - types: [closed] - branches: - - master -jobs: - upload: - if: github.event.pull_request.merged == true && github.repository == 'wechat-miniprogram/miniprogram-demo' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: 'recursive' - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Clone submodule - run: git submodule status - - - name: Install dependencies - run: npm install - - - name: Run package script - run: npm run init - - - name: Upload MiniProgram - env: - WX_PRIVATE_KEY: ${{ secrets.WX_PRIVATE_KEY }} - run: | - mkdir -p ./build - echo "$WX_PRIVATE_KEY" > ./build/key - chmod +x ./build/ci.js - node ./build/ci.js --skip-key-write diff --git a/.github/workflows/pr-lint-check.yml b/.github/workflows/pr-lint-check.yml new file mode 100644 index 00000000..db11cb4f --- /dev/null +++ b/.github/workflows/pr-lint-check.yml @@ -0,0 +1,39 @@ +name: PR Lint Check + +on: + pull_request: + branches: [ master ] + +jobs: + eslint-changed: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v44 + with: + since_last_remote_commit: 'true' + + - name: Filter JavaScript files + id: filter-js + run: | + changed_js_files=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | grep -E '\.(js|ts|jsx|tsx)$' || true) + echo "changed_js_files=${changed_js_files}" >> $GITHUB_OUTPUT + + - name: Run ESLint on changed JS files + if: ${{ steps.filter-js.outputs.changed_js_files != '' }} + run: | + echo "Changed JS files: ${{ steps.filter-js.outputs.changed_js_files }}" + npx eslint ${{ steps.filter-js.outputs.changed_js_files }}