Skip to content

[no-issue] ci: prettier ci 수정 #102

[no-issue] ci: prettier ci 수정

[no-issue] ci: prettier ci 수정 #102

Workflow file for this run

name: Continuous Integration
# This action works with pull requests and pushes on the main branch
on:
pull_request:
push:
branches: [main]
jobs:
prettier:
name: Prettier Check
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Prettier
run: npm install --global prettier@latest
- name: Run Prettier Check
id: prettier-check
run: |
npx prettier --check "**/*.{js,jsx,ts,tsx,css,scss,mdx}" --config ./.prettierrc --ignore-path ./.prettierignore || true
- name: Collect Prettier Output
id: prettier-output
run: |
echo "## Prettier Report" > prettier_report.md
echo "The following files are not formatted:" >> prettier_report.md
npx prettier --list-different "**/*.{js,jsx,ts,tsx,css,scss,mdx}" --config ./.prettierrc --ignore-path ./.prettierignore >> prettier_report.md
echo "" >> prettier_report.md
echo "Detailed formatting differences:" >> prettier_report.md
for file in $(npx prettier --list-different "**/*.{js,jsx,ts,tsx,css,scss,mdx}" --config ./.prettierrc --ignore-path ./.prettierignore); do
echo "Differences in $file:" >> prettier_report.md
npx prettier --write "$file" --config ./.prettierrc --ignore-path ./.prettierignore --loglevel debug || true
echo "" >> prettier_report.md
done
continue-on-error: true
- name: Create Pull Request Comment
if: ${{ failure() }}
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const prettierReport = fs.readFileSync('prettier_report.md', 'utf8');
const { context } = require('@actions/github');
github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: prettierReport
});