diff --git a/Makefile b/Makefile index 0c889da37c084..15e00c92e9164 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,7 @@ DOCS_OUTPUT_DIR ?= generated/docs -DOCS_PUBLISH_DIR ?= ../envoy-docs .PHONY: docs docs: rm -fr generated/docs mkdir -p generated/docs docs/build.sh $(DOCS_OUTPUT_DIR) - -.PHONY: publish_docs -publish_docs: docs - docs/publish.sh $(DOCS_OUTPUT_DIR) $(DOCS_PUBLISH_DIR) - diff --git a/ci/do_ci.sh b/ci/do_ci.sh index bdf1493580fbc..1c14ddf38e116 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -9,6 +9,8 @@ echo "building using $NUM_CPUS CPUs" if [[ "$1" == "docs" ]]; then echo "docs build..." make docs + # this target will run a script that will publish docs on a master commit. + docs/publish.sh exit 0 fi diff --git a/docs/publish.sh b/docs/publish.sh index 70f91c839e2f2..c51af270fdbc6 100755 --- a/docs/publish.sh +++ b/docs/publish.sh @@ -2,20 +2,20 @@ set -e -DOCS_DIR=$1 -PUBLISH_DIR=$2 +DOCS_DIR=generated/docs +PUBLISH_DIR=../envoy-docs BUILD_SHA=`git rev-parse HEAD` -if [[ ! -d $PUBLISH_DIR ]]; then - echo "$PUBLISH_DIR does not exist. Clone a fresh envoy repo." +if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ] +then + git clone https://GH_TOKEN@github.com/lyft/envoy $PUBLISH_DIR + git -C $PUBLISH_DIR config user.name "Publish Docs" + git -C $PUBLISH_DIR config user.email GH_EMAIL + git -C $PUBLISH_DIR fetch + git -C $PUBLISH_DIR checkout -B gh-pages origin/gh-pages + rm -fr $PUBLISH_DIR/* + cp -r $DOCS_DIR/* $PUBLISH_DIR + git -C $PUBLISH_DIR add . + git -C $PUBLISH_DIR commit -m "docs @$BUILD_SHA" + git -C $PUBLISH_DIR push origin gh-pages fi - -git -C $PUBLISH_DIR fetch -git -C $PUBLISH_DIR checkout -B gh-pages origin/gh-pages -rm -fr $PUBLISH_DIR/* -cp -r $DOCS_DIR/* $PUBLISH_DIR -git -C $PUBLISH_DIR add . -git -C $PUBLISH_DIR commit -m "docs @$BUILD_SHA" - -echo -echo "*** YOU MUST MANUALLY PUSH the gh-pages branch after verifying the commit ***"