Created
June 4, 2018 08:42
-
-
Save miyanaga/1a7cfaaf643793526ad487d68a3a50a4 to your computer and use it in GitHub Desktop.
Send lighthouse scores to slack channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
URL="<URL to audit>" | |
SLACK_URL="<Slack channel webhook URL>" | |
SLACK_USER="Lighthouse" | |
lighthouse --output json \ | |
--output-path ./result.json \ | |
--chrome-flags="--headless" \ | |
$URL | |
SCORES=`cat result.json \ | |
| jq -r '.categories | \ | |
map_values("\(.title): \(.score*100)") | \ | |
join(" / ")'` | |
PAYLOAD='{"username":"'$SLACK_USER'", "text":"'$SCORES' ('$URL')"}' | |
curl -X POST -d "$PAYLOAD" $SLACK_URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment