Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "/"
HOST = "/"
[[plugins]]
package = "@algolia/netlify-plugin-crawler"
[plugins.inputs]
branches = ['main','release/*']
disabled = false
renderJavaScript = false
template = "hierarchical"
47 changes: 47 additions & 0 deletions scripts/branchdeploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/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'

# script used to build a release branch
# expect the branch to be named release/<version>
# 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[notes for myself] $1 will be $DEPLOY_PRIME_URL from the config file above.