Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 14, 2020 02:46 pm GMT

Automated lighthouse score to your PR (with Vercel and Github Actions)

TLDR give me the code now!

Imagine a friendly Github Action bot that adds this to all the PRs (per commit) to your repo:

Alt Text

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

  1. Get the preview url for the PR (from Vercel).
  2. Run a Lighthouse audit on the preview url with this plugin.
  3. Format the score to a table (+throw in a few emojis).
  4. 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

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To