신고 목록 조회 response 값이 UI에 보이지 않도록 response 를 가공하여 보여주도록 수정 #143
Workflow file for this run
This file contains 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: Run Lighthouse CI When PR | |
on: | |
pull_request: | |
branches: ['dev'] | |
paths: | |
- 'frontend/**' | |
defaults: | |
run: | |
working-directory: frontend | |
jobs: | |
lhci: | |
permissions: write-all | |
name: Lighthouse CI | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install packages | |
run: npm install | |
- name: Set environment variable | |
run: | | |
touch .env | |
echo VOTOGETHER_BASE_URL=${{ secrets.VOTOGETHER_BASE_URL }} >> .env | |
echo VOTOGETHER_MOCKING_URL=${{ secrets.VOTOGETHER_MOCKING_URL }} >> .env | |
echo VOTOGETHER_REST_API_KEY=${{ secrets.VOTOGETHER_REST_API_KEY }} >> .env | |
echo VOTOGETHER_SERVER_REDIRECT_URL=${{ secrets.VOTOGETHER_SERVER_REDIRECT_URL }} >> .env | |
echo VOTOGETHER_CHANNEL_TALK_KEY=${{ secrets.VOTOGETHER_CHANNEL_TALK_KEY }} >> .env | |
echo VOTOGETHER_GOOGLE_TAG_ID=${{ secrets.VOTOGETHER_GOOGLE_TAG_ID }} >> .env | |
cat .env | |
- name: Build | |
run: npm run build | |
env: | |
VOTOGETHER_BASE_URL: ${{ env.VOTOGETHER_BASE_URL }} | |
VOTOGETHER_MOCKING_URL: ${{ env.VOTOGETHER_MOCKING_URL }} | |
VOTOGETHER_REST_API_KEY: ${{ env.VOTOGETHER_REST_API_KEY }} | |
VOTOGETHER_SERVER_REDIRECT_URL: ${{ env.VOTOGETHER_SERVER_REDIRECT_URL}} | |
VOTOGETHER_CHANNEL_TALK_KEY: ${{ env.VOTOGETHER_CHANNEL_TALK_KEY }} | |
VOTOGETHER_GOOGLE_TAG_ID: ${{ env.VOTOGETHER_GOOGLE_TAG_ID }} | |
- name: Run Lighthouse CI | |
env: | |
LHCI_GITHUB_APP_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
npm install -g @lhci/cli | |
lhci autorun || echo "Fail to Run Lighthouse CI!" | |
- name: Format lighthouse score | |
id: format_lighthouse_score | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs'); | |
const results = JSON.parse(fs.readFileSync('./frontend/lhci_reports/manifest.json')); | |
let comments = ''; | |
results.forEach((result) => { | |
const { summary, jsonPath } = result; | |
const details = JSON.parse(fs.readFileSync(jsonPath)); | |
const { audits } = details; | |
const formatResult = (res) => Math.round(res * 100); | |
Object.keys(summary).forEach( | |
(key) => (summary[key] = formatResult(summary[key])) | |
); | |
const score = (res) => (res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'); | |
const comment = [ | |
`⚡️ Lighthouse report!`, | |
`| Category | Score |`, | |
`| --- | --- |`, | |
`| ${score(summary.performance)} Performance | ${summary.performance} |`, | |
`| ${score(summary.accessibility)} Accessibilty | ${summary.accessibility} |`, | |
`| ${score(summary.seo)} SEO | ${summary.seo} |`, | |
`| ${score(summary.pwa)} PWA | ${summary.pwa} |`, | |
].join('\n'); | |
const detail = [ | |
`| Category | Score |`, | |
`| --- | --- |`, | |
`| ${score(audits['first-contentful-paint'].score * 100)} First Contentful Paint | ${audits['first-contentful-paint'].displayValue} |`, | |
`| ${score(audits['largest-contentful-paint'].score * 100)} Largest Contentful Paint | ${audits['largest-contentful-paint'].displayValue} |`, | |
`| ${score(audits['total-blocking-time'].score * 100)} Total Blocking Time | ${audits['total-blocking-time'].displayValue} |`, | |
`| ${score(audits['cumulative-layout-shift'].score * 100)} Cumulative Layout Shift | ${audits['cumulative-layout-shift'].displayValue} |`, | |
`| ${score(audits['speed-index'].score * 100)} Speed Index | ${audits['speed-index'].displayValue} |`, | |
].join('\n'); | |
comments += comment + '\n\n' + detail + '\n'; | |
}); | |
core.setOutput('comments', comments) | |
- name: comment PR | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
message: ${{ steps.format_lighthouse_score.outputs.comments}} |