diff --git a/netlify.toml b/netlify.toml index 5b17e189..3269b86e 100644 --- a/netlify.toml +++ b/netlify.toml @@ -16,7 +16,7 @@ LOOP = "false" HOST = "/" [context.branch-deploy] - command = "./scripts/branchdeploy.sh $DEPLOY_PRIME_URL" + command = "./scripts/branchdeploy.sh $DEPLOY_PRIME_URL $HEAD" [context.branch-deploy.environment] HUGO_VERSION = "0.79.0" LOOP = "false" diff --git a/scripts/branchdeploy.sh b/scripts/branchdeploy.sh index e4a84993..bfc89f0d 100755 --- a/scripts/branchdeploy.sh +++ b/scripts/branchdeploy.sh @@ -12,14 +12,15 @@ RESET='\033[0m' # script used to build a release branch # expect the branch to be named release/ -# argument is the netlify base url +# argument $1 is the netlify base url +# argument $2 is the $HEAD netlify variable which is the branch name -releaseVersion=$(git rev-parse --abbrev-ref HEAD | sed 's/.*\///') +releaseVersion=$(echo $2 | sed 's/.*\///') echo "branchdeploy => '$releaseVersion'" - -echo "branchdeploy => '$releaseVersion'" - +VERSION_STRING="$releaseVersion" +# In Unix environments, env variables should also be exported to be seen by Hugo +export VERSIONS=${VERSION_STRING} run() { export DGRAPH_ENDPOINT=${DGRAPH_ENDPOINT:-"https://play.dgraph.io/query?latency=true"} @@ -40,9 +41,10 @@ run() { fi popd > /dev/null - echo -e "$(date) $GREEN Generating documentation static pages in the public folder. $RESET" + echo -e "$(date) $GREEN Generating documentation static pages in the folder public/docs/$releaseVersion. $RESET" CURRENT_VERSION=${releaseVersion} \ + VERSIONS=${VERSION_STRING} \ 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" diff --git a/scripts/local.sh b/scripts/local.sh index 981f7e73..eb6e3b03 100755 --- a/scripts/local.sh +++ b/scripts/local.sh @@ -5,6 +5,8 @@ set -e GREEN='\033[32;1m' RESET='\033[0m' +branch=$(git rev-parse --abbrev-ref HEAD) +echo "branch => '$branch'" VERSIONS_ARRAY=( 'preview' ) @@ -54,4 +56,3 @@ run() { } run "$1" "$2" -