2013-09-27 21:50:02 -04:00
|
|
|
#! /bin/bash -e
|
|
|
|
|
2014-08-01 18:12:00 -04:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
version="latest"
|
2013-09-27 21:50:02 -04:00
|
|
|
else
|
2014-08-01 18:12:00 -04:00
|
|
|
version=$1
|
2013-09-27 21:50:02 -04:00
|
|
|
fi
|
|
|
|
|
2014-08-01 18:42:22 -04:00
|
|
|
docs=$(git -C "$(dirname "$0")" rev-parse --show-toplevel)/docs
|
|
|
|
|
|
|
|
if [ -n "$(git -C "$docs" status --porcelain --untracked-files=no content)" ]; then
|
|
|
|
echo "Docs directory is not clean, aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-08-01 18:12:00 -04:00
|
|
|
if [ -z "$(git tag -l "druid-$version")" ] && [ "$version" != "latest" ]; then
|
|
|
|
echo "Version tag does not exist: druid-$version"
|
2013-11-05 18:20:55 -05:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2014-08-01 18:12:00 -04:00
|
|
|
tmp=$(mktemp -d -t druid-docs-deploy)
|
2013-09-27 21:50:02 -04:00
|
|
|
|
2014-08-01 18:12:00 -04:00
|
|
|
echo "Using Version [$version]"
|
|
|
|
echo "Working directory [$tmp]"
|
2013-09-27 21:50:02 -04:00
|
|
|
|
2014-08-01 18:42:22 -04:00
|
|
|
git clone git@github.com:druid-io/druid-io.github.io.git "$tmp"
|
2013-09-27 21:50:02 -04:00
|
|
|
|
2014-08-01 18:12:00 -04:00
|
|
|
target=$tmp/docs/$version
|
2013-09-27 21:50:02 -04:00
|
|
|
|
2014-08-01 18:12:00 -04:00
|
|
|
mkdir -p $target
|
|
|
|
rsync -a --delete "$docs/content/" $target
|
2013-09-27 21:50:02 -04:00
|
|
|
|
2014-08-01 18:12:00 -04:00
|
|
|
branch=update-docs-$version
|
2013-09-27 21:50:02 -04:00
|
|
|
|
2014-08-01 18:42:22 -04:00
|
|
|
git -C $tmp checkout -b $branch
|
2014-08-01 18:12:00 -04:00
|
|
|
git -C $tmp add -A .
|
2014-08-01 18:42:22 -04:00
|
|
|
git -C $tmp commit -m "Update $version docs"
|
|
|
|
git -C $tmp push origin $branch
|
2013-09-27 21:50:02 -04:00
|
|
|
|
2014-08-01 18:12:00 -04:00
|
|
|
if [ -n "$GIT_TOKEN" ]; then
|
2014-08-01 18:42:22 -04:00
|
|
|
curl -u "$GIT_TOKEN:x-oauth-basic" -XPOST -d@- \
|
|
|
|
https://api.github.com/repos/druid-io/druid-io.github.io/pulls <<EOF
|
2014-08-01 18:12:00 -04:00
|
|
|
{
|
2014-08-01 18:42:22 -04:00
|
|
|
"title" : "Update $version docs",
|
2014-08-01 18:12:00 -04:00
|
|
|
"head" : "$branch",
|
|
|
|
"base" : "master"
|
|
|
|
}
|
|
|
|
EOF
|
2014-08-01 18:42:22 -04:00
|
|
|
|
2014-08-01 18:12:00 -04:00
|
|
|
else
|
|
|
|
echo "GitHub personal token not provided, not submitting pull request"
|
2014-08-01 18:42:22 -04:00
|
|
|
echo "Please go to https://github.com/druid-io/druid-io.github.io and submit a pull request from the \`$branch\` branch"
|
2014-08-01 18:12:00 -04:00
|
|
|
fi
|
2013-09-27 21:50:02 -04:00
|
|
|
|
2014-08-01 18:42:22 -04:00
|
|
|
rm -rf $tmp
|