Formatting PR #1
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: Code Formatting Check | |
on: | |
pull_request: | |
branches: [main, develop] | |
jobs: | |
format-check: | |
name: Prettier Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'npm' | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm- | |
${{ runner.os }}- | |
- name: Install Dependencies | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Check formatting | |
run: npm run format:check | |
- name: Comment on PR if formatting issues found | |
if: failure() | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.name, | |
body: '❌ Code formatting check failed. Please run `npm run format:write` locally and commit the changes.' | |
}) |