Skip to content

Commit

Permalink
Lighthouse - send screenshots instead of html
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejslawik committed Feb 6, 2023
1 parent 93d61f3 commit c309f98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ set('lighthouse', (
->setSlackAuthToken('xoxb-XXXXXXX-XXXXXXXXX-XXXXXXXXXXXXXX') // Slack bot token
->setSlackChannels('XXXXXXX') //Slack channels you want the message sent to, comma-separated
->setProjectSlug('project-name')

after('deploy:success', 'lighthouse:generate');
```

and trigger it after your deployment with
```
dep lighthouse:generate
```
4 changes: 4 additions & 0 deletions recipe/custom/lighthouse.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public function validate(): bool
runLocally("lighthouse {$lighthouseConfig->getTargetUrl()} --quiet --no-enable-error-reporting \
--chrome-flags=\"--headless --no-sandbox\" --form-factor=mobile \
--output-path={$lighthouseConfig->getProjectSlug()}-mobile.html {$extraHeaders}");
runLocally("chromium-browser --no-sandbox --headless --screenshot=\"{$lighthouseConfig->getProjectSlug()}-mobile.png\" \
\"{$lighthouseConfig->getProjectSlug()}-mobile.html\"");
runLocally("curl -F file=@{$lighthouseConfig->getProjectSlug()}-mobile.html \
-F \"initial_comment=Here are the mobile :iphone: Lighthouse results for your latest deployment :rocket:\" \
-F channels={$lighthouseConfig->getSlackChannels()} \
Expand All @@ -106,6 +108,8 @@ public function validate(): bool
runLocally("lighthouse {$lighthouseConfig->getTargetUrl()} --quiet --no-enable-error-reporting \
--chrome-flags=\"--headless --no-sandbox\" --form-factor=desktop --screenEmulation.disabled \
--output-path={$lighthouseConfig->getProjectSlug()}-desktop.html {$extraHeaders}");
runLocally("chromium-browser --no-sandbox --headless --screenshot=\"{$lighthouseConfig->getProjectSlug()}-desktop.png\" \
\"{$lighthouseConfig->getProjectSlug()}-desktop.html\"");
runLocally("curl -F file=@{$lighthouseConfig->getProjectSlug()}-desktop.html \
-F \"initial_comment=Here are the desktop :computer: Lighthouse results for your latest deployment :rocket:\" \
-F channels={$lighthouseConfig->getSlackChannels()} \
Expand Down

0 comments on commit c309f98

Please sign in to comment.