Skip to content

Instantly share code, notes, and snippets.

@miyanaga
Created June 4, 2018 08:42
Show Gist options
  • Save miyanaga/1a7cfaaf643793526ad487d68a3a50a4 to your computer and use it in GitHub Desktop.
Save miyanaga/1a7cfaaf643793526ad487d68a3a50a4 to your computer and use it in GitHub Desktop.
Send lighthouse scores to slack channel
#!/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