An Interest In:
Web News this Week
- April 3, 2024
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
Automated lighthouse score to your PR (with Vercel and Github Actions)
Imagine a friendly Github Action bot that adds this to all the PRs (per commit) to your repo:
Green Lighthouse metrics
Web pages with Google Lighthouse metrics that are green (>= 90) tend to be faster, more accessible, and come with a better user experience. If you, as a developer, can help your company improve on these metrics it will directly impact your companies bottom line (+ help with your paid marketing efforts and SEO).
The first step to green Lighthouse metrics is to measure the metrics. Make it easy for you, and your fellow developers, to see how your code changes impact the Lighthouse metrics by including the metrics as a part of your PRs.
Github Action workflow
- Get the preview url for the PR (from Vercel).
- Run a Lighthouse audit on the preview url with this plugin.
- Format the score to a table (+throw in a few emojis).
- Post a comment on the PR with the formatted score.
The comment on the PR will be a sticky comment - e.g. if the comment exists update it else add a new comment.
The complete action can be found here here. Feel free to copy paste this action to your repo.
Not using Vercel?
- Update step 1 of the action (and get the preview url from e.g. Netlify or from your own deployment setup)
Limitations:
- Always runs the Lighthouse audit on the root page.
Further improvements:
- Combine the action with a budget to prevent PRs that bring the metrics below a set treshhold.
- Run the audit only on the pages affected by the PR.
- Compare the collected metrics with the actual metrics of your production site.
Did this help you out? Like and share the article and follow me on Twitter (i'm building Glitterly - a web based video editor).
Original Link: https://dev.to/oskarahl/automated-lighthouse-score-on-your-pr-with-vercel-and-github-actions-2ng2
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To