feat: 测试 #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ESLint Check Changed Files | |
on: | |
push: # 每次推送代码时触发 | |
branches: [ feat-pr-lint ] # 针对这些分支的推送触发 | |
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' # 使用 Node.js 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: | | |
# 只筛选出.js/.ts/.jsx/.tsx文件 | |
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 }} |