Skip to content

fix(chatwoot): fix nullish content field #156

fix(chatwoot): fix nullish content field

fix(chatwoot): fix nullish content field #156

Workflow file for this run

name: Prettier Check
on:
pull_request:
# Runs when PRs to master are opened, re-opened, or new commits are pushed
types: [opened, synchronize, reopened]
branches:
- master
jobs:
prettier-check:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Fetch full git history for base vs head comparison
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.12.4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
# Install dependencies using same method as in the build workflow (directly from package.json, erroring if lockfile is incompatible)
- name: Install dependencies
run: |
if pnpm install --frozen-lockfile; then
echo "Lockfile is compatible"
else
echo "Lockfile incompatible"
exit 1
fi
- name: Get changed files
id: changed_files
shell: bash
run: |
# Strict error handling (stop on errors, error on undefined variables, fail if any command fails)
set -euo pipefail
# PR metadata
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
# Find the common ancestor of the base and head commits
MERGE_BASE=$(git merge-base "$BASE_SHA" "$HEAD_SHA")
# Get all changed files that match Prettier patterns
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMR "$MERGE_BASE" "$HEAD_SHA" -- \
| grep -E '\.(js|mjs|cjs|jsx|ts|mts|cts|tsx|json|ya?ml|md)$' \
| grep -v '^node_modules/' \
| grep -v '/node_modules/' \
| grep -v '^dist/' \
| grep -v '/dist/' \
| grep -v '^bp_modules/' \
| grep -v '/bp_modules/' \
| grep -v '\.min\.js$' \
| grep -v '\.bundle\.js$' \
|| true)
if [ -z "${CHANGED_FILES}" ]; then
echo "has_files=false" >> "$GITHUB_OUTPUT"
echo "No files matching Prettier patterns were changed"
else
# newline -> space
FILES_STR=$(echo "${CHANGED_FILES}" | tr '\n' ' ')
echo "files=${FILES_STR}" >> "$GITHUB_OUTPUT"
echo "has_files=true" >> "$GITHUB_OUTPUT"
echo "Changed files:"
echo "${CHANGED_FILES}"
fi
- name: Check Prettier formatting (pnpm)
if: steps.changed_files.outputs.has_files == 'true'
run: |
CHANGED_FILES="${{ steps.changed_files.outputs.files }}"
echo "Checking formatting for: $CHANGED_FILES"
# Use pnpm's resolver; relies on repo's Prettier version
if ! pnpm exec prettier --check $CHANGED_FILES; then
echo "::error::Some of your changed files are not properly formatted with Prettier"
echo "To fix formatting issues, run: pnpm fix:format"
echo "Or format specific files: pnpm exec prettier --write $CHANGED_FILES"
exit 1
else
echo "All changed files are properly formatted with Prettier ✓"
fi