workflows/lint-checks/action.yaml

30 lines
1.1 KiB
YAML

name: lint-checks
description: >
Node formatting, linting, and conventional-commit checks: prettier
(`format:check`) and eslint (`lint`) npm scripts, each `--if-present`,
plus commitlint if the repo has a commitlint config. Run after
actions/checkout and npm ci (e.g. after node-checks), in a job with node
available.
runs:
using: composite
steps:
- run: npm run format:check --if-present
shell: bash
- run: npm run lint --if-present
shell: bash
- shell: bash
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
if ls commitlint.config.* .commitlintrc* >/dev/null 2>&1; then
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
git fetch origin "$GITHUB_BASE_REF" --depth=1
npx --yes commitlint --from "origin/$GITHUB_BASE_REF" --to HEAD
else
npx --yes commitlint --from HEAD~1 --to HEAD
fi
else
echo "no commitlint config found, skipping conventional-commit check"
fi