Skip to content

ci: fix security_scan push trigger branch and add workflow timeout #7113

ci: fix security_scan push trigger branch and add workflow timeout

ci: fix security_scan push trigger branch and add workflow timeout #7113

Workflow file for this run

name: ESLint & Prettier
on:
pull_request:
branches: [master]
jobs:
lint:
name: Lint and format-check changed JS files
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Get changed JavaScript files
id: get_files
run: |
git diff --diff-filter=ACMRT --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- '*.js' '*.mjs' ':!node_modules/**' > changed-js-files.txt
if [ -s changed-js-files.txt ]; then
echo "has_files=true" >> "$GITHUB_OUTPUT"
else
echo "has_files=false" >> "$GITHUB_OUTPUT"
fi
- name: Run ESLint on changed files
if: steps.get_files.outputs.has_files == 'true'
run: |
echo "Linting the following files:"
cat changed-js-files.txt
xargs -r npx eslint < changed-js-files.txt
- name: Run Prettier check on changed files
if: steps.get_files.outputs.has_files == 'true'
run: |
echo "Checking formatting for the following files:"
cat changed-js-files.txt
xargs -r npx prettier --check < changed-js-files.txt