diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1def57c29..9c9ba2163 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -9,6 +9,26 @@ on: - fix-icon-preview jobs: + lint-filenames: + if: github.repository == 'lucide-icons/lucide' + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: refs/pull/${{ github.event.pull_request.number }}/merge + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: icons/* + - name: Generate annotations + run: node ./scripts/lintFilenames.mjs + env: + CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + lint-contributors: if: github.repository == 'lucide-icons/lucide' runs-on: ubuntu-latest diff --git a/scripts/lintFilenames.mjs b/scripts/lintFilenames.mjs new file mode 100644 index 000000000..053e16650 --- /dev/null +++ b/scripts/lintFilenames.mjs @@ -0,0 +1,24 @@ +import { spawn } from 'child_process'; + +const regex = /(?[^:]+):(?\d+):(?\d+)\s-\s+(?.+)/; +const fileList = (process.env.CHANGED_FILES || '').split(' '); + +const cspell = spawn('npx', ['cspell', 'stdin'], { stdio: ['pipe', 'pipe', 'inherit'] }); +cspell.stdin.write(fileList.join('\n')); +cspell.stdin.end(); + +cspell.stdout.on('data', (data) => { + console.log(data.toString()); + data + .toString() + .split('\n') + .forEach((line) => { + const match = line.match(regex); + if (match) { + const { line, message } = match.groups; + console.log(`::error file=${fileList[line - 1]},line=1,column=1::${message}`); + } + }); +}); + +cspell.on('exit', process.exit);