analytics.home-assistant.io/script/build

72 lines
2.3 KiB
Bash
Executable File

#! /bin/bash
# Build the site
declare addons
declare custom_integrations
declare data
declare integration_details
declare addons_path="${PWD}/site/src/_data/addons.json"
declare custom_integrations_path="${PWD}/site/src/_data/custom_integrations.json"
declare data_path="${PWD}/site/src/_data/data.json"
declare integration_details_path="${PWD}/site/src/_data/integration_details.json"
# Stop on errors
set -e
cd "$(dirname "$0")/.."
rm -rf ./site/dist
mkdir -p ./site/src/_data
if [ -n "$CF_KV_TOKEN" ]; then
if [ -n "$INCOMING_HOOK_URL" ]; then
sleep 61 # Wait for KV writes to reach all nodes
fi
if [ "$BRANCH" = "dev" ]; then
addons=$(curl -sSLf "$CF_KV_URL_ADDONS_DEV" \
-H "Authorization: Bearer $CF_KV_TOKEN" \
-H "Content-Type:application/json")
custom_integrations=$(curl -sSLf "$CF_KV_URL_CUSTOM_INTEGRATIONS_DEV" \
-H "Authorization: Bearer $CF_KV_TOKEN" \
-H "Content-Type:application/json")
data=$(curl -sSLf "$CF_KV_URL_DEV" \
-H "Authorization: Bearer $CF_KV_TOKEN" \
-H "Content-Type:application/json")
integration_details=$(curl -sSLf https://rc.home-assistant.io/integrations.json)
else
addons=$(curl -sSLf "$CF_KV_URL_ADDONS" \
-H "Authorization: Bearer $CF_KV_TOKEN" \
-H "Content-Type:application/json")
custom_integrations=$(curl -sSLf "$CF_KV_URL_CUSTOM_INTEGRATIONS" \
-H "Authorization: Bearer $CF_KV_TOKEN" \
-H "Content-Type:application/json")
data=$(curl -sSLf "$CF_KV_URL" \
-H "Authorization: Bearer $CF_KV_TOKEN" \
-H "Content-Type:application/json")
integration_details=$(curl -sSLf https://www.home-assistant.io/integrations.json)
fi
else
addons=$(curl -sSLf https://analytics.home-assistant.io/addons.json)
custom_integrations=$(curl -sSLf https://analytics.home-assistant.io/custom_integrations.json)
data=$(curl -sSLf https://analytics.home-assistant.io/data.json)
integration_details=$(curl -sSLf https://www.home-assistant.io/integrations.json)
fi
# Export to files
echo "$addons" | jq . > "$addons_path"
echo "$custom_integrations" | jq . > "$custom_integrations_path"
echo "$data" | jq . > "$data_path"
echo "$integration_details" | jq . > "$integration_details_path"
if [ ! -d node_modules ]; then
script/bootstrap
fi
cd ./site
NODE_ENV="production" ../node_modules/.bin/eleventy