Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 9 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 51 additions & 14 deletions .github/workflows/prettier-check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Continuous Integration

# This action works with pull requests and pushes on the main branch
on:
pull_request:
push:
Expand All @@ -14,18 +13,56 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Run Prettier
id: prettier-run
uses: rutajdash/[email protected]
- name: Setup Node.js
uses: actions/setup-node@v2
with:
config_path: './.prettierrc'
file_pattern: '**/*'

# This step only runs if prettier finds errors causing the previous step to fail
# This steps lists the files where errors were found
- name: Prettier Output
if: ${{ failure() }}
shell: bash
node-version: '14'

- name: Install Prettier
run: npm install 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
continue-on-error: true

- name: Collect Prettier Output
if: steps.prettier-check.outcome == 'failure'
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 || true
echo "" >> prettier_report.md
echo "Detailed formatting differences:" >> prettier_report.md
while IFS= read -r file; do
if [ -n "$file" ]; then
echo "Differences in $file:" >> prettier_report.md
npx prettier "$file" --config ./.prettierrc --ignore-path ./.prettierignore > formatted_file.tmp 2>/dev/null || true
diff -u "$file" formatted_file.tmp >> prettier_report.md 2>/dev/null || true
echo "" >> prettier_report.md
fi
done < <(npx prettier --list-different "**/*.{js,jsx,ts,tsx,css,scss,mdx}" --config ./.prettierrc --ignore-path ./.prettierignore)
continue-on-error: true

- name: Create Pull Request Comment
if: steps.prettier-check.outcome == 'failure' && github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{secrets.ACTION_PAT}}
script: |
const fs = require('fs');
const prettierReport = fs.readFileSync('prettier_report.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: prettierReport
});

- name: Fail if Prettier found issues
if: steps.prettier-check.outcome == 'failure'
run: |
echo "The following files are not formatted:"
echo "${{steps.prettier-run.outputs.prettier_output}}"
echo "Prettier found formatting issues. Please fix them and try again."
exit 1
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build:local": "pnpm run generate-sitemap && next build",
"start": "next start",
"lint": "next lint --cache",
"format": "prettier --cache --check .",
"format:fix": "prettier --cache --write --log-level warn . --ignore-path .prettierignore",
"format": "prettier --cache --check \"**/*.{js,jsx,ts,tsx,css,scss,mdx}\"",
"format:fix": "prettier --cache --write --ignore-path .prettierignore \"**/*.{js,jsx,ts,tsx,css,scss,mdx}\"",
"prepare": "husky",
"lint-staged": "pnpm format:fix && pnpm lint",
"generate-sitemap": "node scripts/generate-sitemap.mjs"
Expand Down
2 changes: 1 addition & 1 deletion pages/docs/pages/api-reference/components/image-legacy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Backwards compatible Image Optimization with the Legacy Image compo

{/* TODO: 번역이 필요합니다. */}

# `<Image>` (Legacy)
`<Image>` (Legacy)

<details>
<summary>Examples</summary>
Expand Down
Loading