name: Pull Request Validation
on:
pull_request:
branches: [ main ]
jobs:
validate:
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: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Validate Conventional Commits
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
- name: Build
run: npm run build
- name: Run Tests
run: |
if [ -f "package.json" ] && grep -q "\"test\":" "package.json"; then
npm test
else
echo "No test script found in package.json"
fi