From 3da0f839b424c7747a160fece4e0bc63fe87b861 Mon Sep 17 00:00:00 2001 From: rderbier Date: Fri, 27 Jan 2023 14:32:33 -0800 Subject: [PATCH 1/3] change build script for branches --- netlify.toml | 12 ++++++++++-- scripts/branchdeploy.sh | 42 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 scripts/branchdeploy.sh diff --git a/netlify.toml b/netlify.toml index 4b9bb164..5b17e189 100644 --- a/netlify.toml +++ b/netlify.toml @@ -15,8 +15,16 @@ HUGO_VERSION = "0.79.0" LOOP = "false" HOST = "/" - +[context.branch-deploy] + command = "./scripts/branchdeploy.sh $DEPLOY_PRIME_URL" [context.branch-deploy.environment] HUGO_VERSION = "0.79.0" LOOP = "false" - HOST = "/" \ No newline at end of file + HOST = "/" +[[plugins]] + package = "@algolia/netlify-plugin-crawler" + [plugins.inputs] + branches = ['main','release/*'] + disabled = false + renderJavaScript = false + template = "hierarchical" diff --git a/scripts/branchdeploy.sh b/scripts/branchdeploy.sh new file mode 100644 index 00000000..f200cec7 --- /dev/null +++ b/scripts/branchdeploy.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -e + +GREEN='\033[32;1m' +RESET='\033[0m' + +# script used to build a release branch +# expect the branch to be named release/ +# argument is the netlify base url + +releaseVersion=$(git rev-parse --abbrev-ref HEAD | sed 's/release\///') + + +run() { + export DGRAPH_ENDPOINT=${DGRAPH_ENDPOINT:-"https://play.dgraph.io/query?latency=true"} + export HUGO_TITLE="Dgraph Doc - Preview" \ + + pushd "$(dirname "$0")/.." > /dev/null + pushd themes > /dev/null + + if [ ! -d "hugo-docs" ]; then + echo -e "$(date) $GREEN Hugo-docs repository not found. Cloning the repo. $RESET" + git clone https://github.com/dgraph-io/hugo-docs.git + else + echo -e "$(date) $GREEN Hugo-docs repository found. Pulling the latest version from master. $RESET" + pushd hugo-docs > /dev/null + git checkout master + git pull + popd > /dev/null + fi + popd > /dev/null + + echo -e "$(date) $GREEN Generating documentation static pages in the public folder. $RESET" + hugo --destination="public/docs/$releaseVersion" --baseURL="$1/docs/$releaseVersion" 1> /dev/null + cp "public/docs/$releaseVersion/sitemap.xml" public > /dev/null + echo -e "$(date) $GREEN Done building. $RESET" + + popd > /dev/null +} + +run "$1" From 32f22cee0929f329b739bf3d475e0ebb3225a313 Mon Sep 17 00:00:00 2001 From: rderbier Date: Fri, 27 Jan 2023 14:42:53 -0800 Subject: [PATCH 2/3] add clean builds --- scripts/branchdeploy.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/branchdeploy.sh b/scripts/branchdeploy.sh index f200cec7..62bc3b6e 100644 --- a/scripts/branchdeploy.sh +++ b/scripts/branchdeploy.sh @@ -1,6 +1,11 @@ #!/bin/bash set -e +# Important for clean builds on Netlify +if ! git remote | grep -q origin ; then + git remote add origin https://github.com/dgraph-io/dgraph-docs.git + git fetch --all +fi GREEN='\033[32;1m' RESET='\033[0m' From 42920e852bcc248bdc613a3843daea691f708b20 Mon Sep 17 00:00:00 2001 From: rderbier Date: Fri, 27 Jan 2023 16:20:51 -0800 Subject: [PATCH 3/3] minor change to trigger a netlify deploy --- scripts/branchdeploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/branchdeploy.sh b/scripts/branchdeploy.sh index 62bc3b6e..09f5e841 100644 --- a/scripts/branchdeploy.sh +++ b/scripts/branchdeploy.sh @@ -15,7 +15,7 @@ RESET='\033[0m' # argument is the netlify base url releaseVersion=$(git rev-parse --abbrev-ref HEAD | sed 's/release\///') - +echo "branchdeploy => '$releaseVersion'" run() { export DGRAPH_ENDPOINT=${DGRAPH_ENDPOINT:-"https://play.dgraph.io/query?latency=true"}