#!/bin/bash set -e if [ -z "$NOW_TOKEN" ]; then echo "NOW_TOKEN is not set; skipping docs deployment" else if [[ -e primer-version.txt ]]; then version=$(cat primer-version.txt) else version=$(jq -r .version modules/primer/package.json) fi cd docs npm run sync actual=$(jq -r .dependencies.primer package.json) if [[ "$version" != "$actual" ]]; then # here, we need to manually update the primer dependency # version to the one that we published echo "primer has '$version' in package.json; docs wants '$actual'" jq ".dependencies.primer = \"$version\"" package.json > package.json.tmp mv package.json.tmp package.json fi now_args="--token=$NOW_TOKEN" npx commit-status pending docs "deploying v$version docs..." echo "deploying..." now "$now_args" | tee now-url.txt url=$(cat now-url.txt) npx commit-status success docs "v$version docs: $url" "$url" if [[ $TRAVIS_EVENT_TYPE = "pull_request" ]]; then branch=$TRAVIS_PULL_REQUEST_BRANCH else branch=$TRAVIS_BRANCH fi if [[ "$branch" = "master" ]]; then alias=$(jq -r .alias now.json) else alias="primer-css-${branch//\./-}.now.sh" fi echo "aliasing to '$alias'..." now "$now_args" alias "$url" "$alias" npx commit-status success docs "v$version docs: $alias" "https://$alias" if [[ "$CHECK_LINKS" = "1" ]]; then echo echo "Running script/check-links in $(pwd)..." echo script/check-links -v -m=5 "https://$alias/css" || { echo echo "⚠️ Link check failed! ⚠️" echo echo "Check the report above for more info, and/or run:" echo echo " script/check-links http://localhost:3000 -v" echo echo "locally for more info." exit 1 } else echo "Set CHECK_LINKS=1 to check links on Travis" fi fi