diff --git a/build.sh b/build.sh index a5e150320..b48b1f5ba 100644 --- a/build.sh +++ b/build.sh @@ -1,7 +1,42 @@ -# ensures that we always use the latest version of the script -if [ -f build-site.sh ]; then - rm build-site.sh -fi +PARSER_VERSION=0.18.14 +# This make command curls the examples for certain repos. +# If the rule doesn't exist, the error doesn't interrupt the build process. +make examples -curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/netlify-poc/scripts/build-site.sh -o build-site.sh -sh build-site.sh +echo "Printing branch name ${BRANCH_NAME}" +echo "branch using git branch ${BRANCH}" + +TEST_VAL=git rev-parse --abbrev-ref HEAD +echo "testing val ${TEST_VAL}" + +if [ ! -d "snooty-parser" ]; then + echo "snooty parser not installed, downloading..." + curl -L -o snooty-parser.zip https://github.com/mongodb/snooty-parser/releases/download/v${PARSER_VERSION}/snooty-v${PARSER_VERSION}-linux_x86_64.zip + unzip -d ./snooty-parser snooty-parser.zip + chmod +x ./snooty-parser/snooty +fi + +echo "=======================================================================================================================================================================" +echo "========================================================================== Running parser... ==========================================================================" +./snooty-parser/snooty/snooty build . --no-caching --output=./bundle.zip --branch="${BRANCH_NAME}" +echo "========================================================================== Parser complete ============================================================================" +echo "=======================================================================================================================================================================" + +if [ ! -d "snooty" ]; then + echo "snooty frontend not installed, downloading" + git clone -b netlify-pageId-hotfix --depth 1 https://github.com/mongodb/snooty.git + echo GATSBY_MANIFEST_PATH=$(pwd)/bundle.zip >> ./snooty/.env.production + cd snooty + npm ci --legacy-peer-deps + git clone --depth 1 https://github.com/mongodb/docs-tools.git ./snooty/docs-tools + mkdir -p ./snooty/static/images + mv ./snooty/docs-tools/themes/mongodb/static ./static/docs-tools + mv ./snooty/docs-tools/themes/guides/static/images/bg-accent.svg ./static/docs-tools/images/bg-accent.svg +fi + +if [ -d "docs-worker-pool" ]; then + node --unhandled-rejections=strict docs-worker-pool/modules/persistence/dist/index.js --path bundle.zip --githubUser netlify +fi + + +cd snooty && npm run build:no-prefix diff --git a/netlify.toml b/netlify.toml index d0c890406..fdc70b72c 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,4 +3,4 @@ name = "snooty-cache-plugin" [build] publish = "snooty/public" -command = ". ./build.sh" +command = ". ./build.sh"