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 }}