Skip to content

Amina/ redirection from deriv-app to Accounts OS application for POI submission #107745

Amina/ redirection from deriv-app to Accounts OS application for POI submission

Amina/ redirection from deriv-app to Accounts OS application for POI submission #107745

Workflow file for this run

name: Generate Lighthouse report
permissions:
actions: write
checks: write
contents: write
deployments: write
pull-requests: write
statuses: write
on:
issue_comment:
types: [edited]
jobs:
generate_lighthouse_report:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout to repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: 1
ref: master
- name: Add Lighthouse progress comment
id: generate_lighthouse_comment
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{github.event.issue.number}}
header: generate_lighthouse_comment
message: "⏳ **Generating Lighthouse report...**"
- name: Capture Vercel preview URL
id: vercel_preview_url
uses: binary-com/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
preview_url_regexp: \[Visit Preview\]\((.*?.sx)\)
- name: Generate Lighthouse report
uses: treosh/lighthouse-ci-action@03becbfc543944dd6e7534f7ff768abb8a296826
id: lighthouse_report
with:
temporaryPublicStorage: true
urls: |
${{ steps.vercel_preview_url.outputs.vercel_preview_url }}
uploadArtifacts: true
# configure Lighthouse score assertions in this file
# configPath: .github/lighthouse/lighthouserc.json
- name: Retrieve Lighthouse score
id: lighthouse_score
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const result = ${{ steps.lighthouse_report.outputs.manifest }}[0].summary
const links = ${{ steps.lighthouse_report.outputs.links }}
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟧' : '🔺'
const formatResult = (res) => Math.round((res * 100))
Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
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 with [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
].join('\n')
core.setOutput("comment", comment);
- name: Post Lighthouse report
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: Lighthouse report
number: ${{github.event.issue.number}}
message: ${{steps.lighthouse_score.outputs.comment}}
- name: Clear Lighthouse progress comment
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{github.event.issue.number}}
header: generate_lighthouse_comment
delete: true