2017-04-10 14:24:53 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -ex
|
2020-01-21 14:36:12 +00:00
|
|
|
|
2017-04-10 14:24:53 +00:00
|
|
|
BASE_DIR=$(dirname $(readlink -f $0))
|
2019-03-26 09:50:28 +00:00
|
|
|
BUILD_DIR="${BASE_DIR}/../build"
|
2020-01-28 18:51:44 +00:00
|
|
|
PUBLISH_DIR="${BASE_DIR}/../publish"
|
2017-04-10 14:24:53 +00:00
|
|
|
IMAGE="clickhouse/website"
|
2020-01-29 14:56:52 +00:00
|
|
|
GIT_TEST_URI="git@github.com:ClickHouse/clickhouse-test.github.io.git"
|
|
|
|
GIT_PROD_URI="git@github.com:ClickHouse/clickhouse.github.io.git"
|
|
|
|
|
2017-04-10 14:24:53 +00:00
|
|
|
if [[ -z "$1" ]]
|
|
|
|
then
|
|
|
|
TAG=$(head -c 8 /dev/urandom | xxd -p)
|
|
|
|
else
|
|
|
|
TAG="$1"
|
|
|
|
fi
|
|
|
|
FULL_NAME="${IMAGE}:${TAG}"
|
|
|
|
REMOTE_NAME="registry.yandex.net/${FULL_NAME}"
|
2017-05-30 14:21:04 +00:00
|
|
|
DOCKER_HASH="$2"
|
2017-04-10 14:24:53 +00:00
|
|
|
if [[ -z "$1" ]]
|
|
|
|
then
|
2019-03-26 09:50:28 +00:00
|
|
|
source "${BASE_DIR}/venv/bin/activate"
|
2019-04-08 16:01:54 +00:00
|
|
|
python "${BASE_DIR}/build.py" "--enable-stable-releases"
|
2020-01-28 18:51:44 +00:00
|
|
|
rm -rf "${PUBLISH_DIR}" || true
|
2020-01-29 14:56:52 +00:00
|
|
|
git clone "${GIT_TEST_URI}" "${PUBLISH_DIR}"
|
2020-01-28 18:51:44 +00:00
|
|
|
cd "${PUBLISH_DIR}"
|
2020-01-29 13:36:13 +00:00
|
|
|
git config user.email "robot-clickhouse@yandex-team.ru"
|
|
|
|
git config user.name "robot-clickhouse"
|
2020-01-28 18:51:44 +00:00
|
|
|
git rm -rf *
|
|
|
|
git commit -a -m "wipe old release"
|
|
|
|
cp -R "${BUILD_DIR}"/* .
|
2020-01-29 14:56:52 +00:00
|
|
|
echo -n "test.clickhouse.tech" > CNAME
|
2020-01-28 19:47:58 +00:00
|
|
|
echo -n "" > README.md
|
2020-01-28 19:31:35 +00:00
|
|
|
cp "${BASE_DIR}/../../LICENSE" .
|
2020-01-28 18:51:44 +00:00
|
|
|
git add *
|
|
|
|
git commit -a -m "add new release at $(date)"
|
|
|
|
git push origin master
|
2019-03-26 09:50:28 +00:00
|
|
|
cd "${BUILD_DIR}"
|
|
|
|
docker build -t "${FULL_NAME}" "${BUILD_DIR}"
|
2017-04-10 14:24:53 +00:00
|
|
|
docker tag "${FULL_NAME}" "${REMOTE_NAME}"
|
2017-05-30 14:21:04 +00:00
|
|
|
DOCKER_HASH=$(docker push "${REMOTE_NAME}" | tail -1 | awk '{print $3;}')
|
2017-05-30 15:36:50 +00:00
|
|
|
docker rmi "${FULL_NAME}"
|
2020-01-29 14:56:52 +00:00
|
|
|
else
|
|
|
|
rm -rf "${BUILD_DIR}" || true
|
|
|
|
rm -rf "${PUBLISH_DIR}" || true
|
|
|
|
git clone "${GIT_TEST_URI}" "${BUILD_DIR}"
|
|
|
|
git clone "${GIT_PROD_URI}" "${PUBLISH_DIR}"
|
|
|
|
cd "${PUBLISH_DIR}"
|
|
|
|
git config user.email "robot-clickhouse@yandex-team.ru"
|
|
|
|
git config user.name "robot-clickhouse"
|
|
|
|
git rm -rf *
|
|
|
|
git commit -a -m "wipe old release"
|
|
|
|
rm -rf "${BUILD_DIR}/.git"
|
|
|
|
cp -R "${BUILD_DIR}"/* .
|
|
|
|
echo -n "clickhouse.tech" > CNAME
|
|
|
|
git add *
|
|
|
|
git commit -a -m "add new release at $(date)"
|
|
|
|
git push origin master
|
2017-04-10 14:24:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
QLOUD_ENDPOINT="https://platform.yandex-team.ru/api/v1"
|
|
|
|
QLOUD_PROJECT="clickhouse.clickhouse-website"
|
|
|
|
if [[ -z "$1" ]]
|
|
|
|
then
|
|
|
|
QLOUD_ENV="${QLOUD_PROJECT}.test"
|
|
|
|
else
|
|
|
|
QLOUD_ENV="${QLOUD_PROJECT}.prod"
|
|
|
|
fi
|
|
|
|
QLOUD_COMPONENT="${QLOUD_ENV}.nginx"
|
2019-04-17 13:32:15 +00:00
|
|
|
QLOUD_VERSION=$(curl -v -H "Authorization: OAuth ${QLOUD_TOKEN}" "${QLOUD_ENDPOINT}/environment/status/${QLOUD_ENV}" | python -c "import json; import sys; print json.loads(sys.stdin.read()).get('version')")
|
|
|
|
curl -v -H "Authorization: OAuth ${QLOUD_TOKEN}" -H "Content-Type: application/json" --data "{\"repository\": \"${REMOTE_NAME}\", \"hash\": \"${DOCKER_HASH}\"}" "${QLOUD_ENDPOINT}/component/${QLOUD_COMPONENT}/${QLOUD_VERSION}/deploy" > /dev/null
|
2017-04-10 14:24:53 +00:00
|
|
|
|
2017-05-30 14:21:04 +00:00
|
|
|
echo ">>> Successfully deployed ${TAG} ${DOCKER_HASH} to ${QLOUD_ENV} <<<"
|