Skip to content

Refactoring and improvements #75

Refactoring and improvements

Refactoring and improvements #75

Workflow file for this run

name: Lint
on:
pull_request:
push:
branches:
- main
jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up pnpm
uses: pnpm/[email protected]
with:
version: latest
- name: Install dependencies
run: pnpm install
- name: Check for formatting issues
id: prettier-check
run: |
pnpm exec prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}"
continue-on-error: true
- name: Set formatting result
id: set-formatting-result
run: |
if grep -q "Code style issues found" <<<"${{ steps.prettier-check.outputs.stdout }}"; then
echo "formatting-required=true" >> $GITHUB_ENV
else
echo "formatting-required=false" >> $GITHUB_ENV
fi
- name: Comment on the PR if formatting is required
if: env.formatting-required == 'true'
uses: actions/github-script@v7
with:
script: |
const issue_number = context.payload.pull_request.number;
github.rest.issues.createComment({
issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Some files aren't properly formatted. Would you like me to lint them for you?"
})
- name: Run Prettier
if: env.formatting-required == 'true'
run: pnpm exec prettier --write "**/*.{js,jsx,ts,tsx,json,css,md}"