Skip to content

πŸ› Fix: λΉŒλ“œμ—λŸ¬ ν•΄κ²° #9

πŸ› Fix: λΉŒλ“œμ—λŸ¬ ν•΄κ²°

πŸ› Fix: λΉŒλ“œμ—λŸ¬ ν•΄κ²° #9

Workflow file for this run

name: Lighthouse CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Run Lighthouse CI
run: pnpm lighthouse:ci
- name: Upload Lighthouse HTML reports
uses: actions/upload-artifact@v4
if: always()
with:
name: lighthouse-html-reports
path: lighthouse-reports/
retention-days: 30
- name: Upload Lighthouse results
uses: actions/upload-artifact@v4
if: always()
with:
name: lighthouse-results
path: .lighthouseci/
retention-days: 30
- name: Comment PR with Korean Lighthouse results
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
try {
const resultsPath = '.lighthouseci/assertion-results.json';
if (fs.existsSync(resultsPath)) {
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8'));
let comment = '## οΏ½οΏ½ Lighthouse CI μ„±λŠ₯ ν…ŒμŠ€νŠΈ κ²°κ³Ό\n\n';
if (results.length === 0) {
comment += 'βœ… λͺ¨λ“  Lighthouse 검사가 ν†΅κ³Όν–ˆμŠ΅λ‹ˆλ‹€!\n';
} else {
comment += '⚠️ 일뢀 Lighthouse κ²€μ‚¬μ—μ„œ λ¬Έμ œκ°€ λ°œκ²¬λ˜μ—ˆμŠ΅λ‹ˆλ‹€:\n\n';
// ν•œκΈ€ λ©”μ‹œμ§€ λ§€ν•‘
const koreanMessages = {
'largest-contentful-paint': 'κ°€μž₯ 큰 μ½˜ν…μΈ κ°€ ν‘œμ‹œλ˜λŠ” μ‹œκ°„ (LCP)',
'first-contentful-paint': '첫 번째 μ½˜ν…μΈ κ°€ ν‘œμ‹œλ˜λŠ” μ‹œκ°„ (FCP)',
'cumulative-layout-shift': 'λˆ„μ  λ ˆμ΄μ•„μ›ƒ 이동 (CLS)',
'total-blocking-time': '총 차단 μ‹œκ°„ (TBT)',
'categories:performance': 'μ„±λŠ₯ 점수',
'categories:accessibility': 'μ ‘κ·Όμ„± 점수',
'categories:seo': 'SEO 점수',
'categories:best-practices': 'λͺ¨λ²” 사둀 점수'
};
results.forEach(result => {
const status = result.passed ? 'βœ…' : '❌';
const koreanTitle = koreanMessages[result.auditId] || result.auditTitle;
const value = result.auditId.includes('categories:') ?
`${(result.actual * 100).toFixed(0)}점` :
`${result.actual}ms`;
const expected = result.auditId.includes('categories:') ?
`${(result.expected * 100).toFixed(0)}점 이상` :
`${result.expected}ms μ΄ν•˜`;
comment += `${status} **${koreanTitle}**: ${value} (κΈ°μ€€: ${expected})\n`;
});
}
comment += '\nπŸ“Š [상세 λ³΄κ³ μ„œ λ‹€μš΄λ‘œλ“œ](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})';
comment += '\n\nοΏ½οΏ½ **μ„±λŠ₯ κ°œμ„  ꢌμž₯사항**:';
comment += '\n- 이미지 μ΅œμ ν™” (WebP 포맷, μ μ ˆν•œ 크기)';
comment += '\n- 폰트 사전 λ‘œλ“œ 및 μ΅œμ ν™”';
comment += '\n- μ€‘μš” λ¦¬μ†ŒμŠ€ 사전 λ‘œλ“œ';
comment += '\n- CDN μ‚¬μš© 및 캐싱 κ°œμ„ ';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
} catch (error) {
console.log('Error creating comment:', error);
}