Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
367 views
in Technique[技术] by (71.8m points)

javascript - Lighthouse yml configuration with Vercel preview

I have the following Lighthouse yml config:

name: Vercel Preview URL Lighthouse Audit

on:
  issue_comment:
    types: [edited]

jobs:
  generate_lighthouse_audit:
    timeout-minutes: 30
    runs-on: ubuntu-latest
    steps:
      - name: Add comment to PR
        id: loading_comment_to_pr
        uses: marocchino/sticky-pull-request-comment@v1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          number: ${{ github.event.issue.number }}
          header: lighthouse
          message: |
            Running Lighthouse audit...
      - name: Capture Vercel preview URL
        id: vercel_preview_url
        uses: aaron-binary/[email protected]
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - uses: actions/checkout@v2
      - name: Audit preview URL with Lighthouse
        id: lighthouse_audit
        uses: treosh/lighthouse-ci-action@v3
        with:
          urls: |
            ${{ steps.vercel_preview_url.outputs.vercel_preview_url }}
          uploadArtifacts: true
          temporaryPublicStorage: true
      - name: Format lighthouse score
        id: format_lighthouse_score
        uses: actions/github-script@v3
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary
            const links = ${{ steps.lighthouse_audit.outputs.links }}
            const formatResult = (res) => Math.round((res * 100))
            Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
            const score = res => res >= 90 ? '??' : res >= 50 ? '??' : '??'
            const comment = [
                `?? [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`,
                '| Category | Score |',
                '| --- | --- |',
                `| ${score(result.performance)} Performance | ${result.performance} |`,
                `| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`,
                `| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`,
                `| ${score(result.seo)} SEO | ${result.seo} |`,
                `| ${score(result.pwa)} PWA | ${result.pwa} |`,
                ' ',
                `*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
            ].join('
')
             core.setOutput("comment", comment);
      - name: Add comment to PR
        id: comment_to_pr
        uses: marocchino/sticky-pull-request-comment@v1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          number: ${{ github.event.issue.number }}
          header: lighthouse
          message: |
            ${{ steps.format_lighthouse_score.outputs.comment }}

however this runs only on ${{ steps.vercel_preview_url.outputs.vercel_preview_url }} I have tried to do the following:

      urls: "
        ${{ steps.vercel_preview_url.outputs.vercel_preview_url }}, 
        ${{ steps.vercel_preview_url.outputs.vercel_preview_url }}/blog,  
        ${{ steps.vercel_preview_url.outputs.vercel_preview_url }}/blog/insights"

but it only runs on: ${{ steps.vercel_preview_url.outputs.vercel_preview_url }}. Is there a way to make multiple urls checked?

question from:https://stackoverflow.com/questions/65918717/lighthouse-yml-configuration-with-vercel-preview

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...