π Fix: λΉλμλ¬ ν΄κ²° #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |