Skip to content

Commit

Permalink
[no-issue] ci: prettier ci 수정 (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
luciancah authored Aug 5, 2024
1 parent 80e2139 commit 973952d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 17 deletions.
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

0 comments on commit 973952d

Please sign in to comment.