Added Linting as a part of CI #4
Workflow file for this run
This file contains 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: CI and Lint | |
on: | |
pull_request: | |
branches: [ main ] | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint changed files | |
if: github.event_name == 'pull_request' | |
run: | | |
git fetch origin ${{ github.base_ref }} | |
FILES=$(git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }} | grep -E '\.(js|jsx|ts|tsx|html|css)$' || true) | |
if [ -n "$FILES" ]; then | |
echo "Linting changed files:" | |
echo "$FILES" | |
echo "$FILES" | xargs npx prettier --check | |
echo "$FILES" | grep -E '\.(js|jsx|ts|tsx)$' | xargs npx eslint || true | |
else | |
echo "No relevant files changed." | |
fi | |
env: | |
CI: true |