From cc539e4ec13837e9e38da13a66c756b37bc485a7 Mon Sep 17 00:00:00 2001 From: instinxt Date: Mon, 5 May 2025 22:43:03 +0530 Subject: [PATCH] add: github actions to lint and npm audit --- .github/workflows/lint_audit.yml | 41 +++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint_audit.yml b/.github/workflows/lint_audit.yml index 43a64ce..2f5c3ca 100644 --- a/.github/workflows/lint_audit.yml +++ b/.github/workflows/lint_audit.yml @@ -5,7 +5,46 @@ on: branches: [main, master, develop] pull_request: branches: [main, master, develop] + paths: + - '**/*.js' + - '**/*.ts' + - '**/*.tsx' + - '**/*.jsx' + - 'package.json' + - 'package-lock.json' jobs: lint-and-audit: - uses: PSMRI/.github/.github/workflows/lint_audit.yml@main + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '16.x' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v35 + with: + files: | + **/*.js + **/*.ts + **/*.tsx + **/*.jsx + + - name: Run ESLint on changed files + if: steps.changed-files.outputs.any_changed == 'true' + run: | + npx eslint ${{ steps.changed-files.outputs.all_changed_files }} + + - name: Run npm audit + if: ${{ contains(steps.changed-files.outputs.all_changed_files, 'package.json') || contains(steps.changed-files.outputs.all_changed_files, 'package-lock.json') }} + run: npm audit