Skip to content

Commit

Permalink
devops: run lhci on bot and user landings (#76)
Browse files Browse the repository at this point in the history
* devops: debug github actions

* devops: run lhci on bot and user landings

* devops: run lhci on bot and user landings
  • Loading branch information
gaboesquivel authored Apr 6, 2024
1 parent 88c230d commit 1f2e01e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,29 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const manifest = ${{ toJSON(steps.lighthouse_audit.outputs.manifest) }};
const links = ${{ toJSON(steps.lighthouse_audit.outputs.links) }};
if (!manifest || Object.keys(manifest).length === 0) {
core.setFailed('Lighthouse audit did not generate any results.');
return;
}
const formatResult = (res) => Math.round((res * 100));
const score = (res) => (res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴');
let comment = `⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:\n`;
comment += '| Category | Score |\n';
comment += '| --- | --- |\n';
let comment
Object.keys(manifest).forEach((page) => {
comment += `*Lighthouse ran on [${pageLink}](${pageLink})*\n\n`;
comment += '| Category | Score |\n';
comment += '| --- | --- |\n';
const result = manifest[page].summary;
const pageLink = manifest[page].url;
Object.keys(result).forEach((key) => {
const formattedScore = formatResult(result[key]);
comment += `| ${score(result[key])} ${key} | ${formattedScore} |\n`;
});
comment += `*Lighthouse ran on [${pageLink}](${pageLink})*\n\n`;
});

core.setOutput('comment', comment);
Expand Down

0 comments on commit 1f2e01e

Please sign in to comment.