diff --git a/.gitignore b/.gitignore index 9ee14c77b..5bfb2ce5f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,6 @@ coverage/ .vscode/ .env .swc/ -bundle.zip \ No newline at end of file +bundle.zip +# Local Netlify folder +.netlify diff --git a/README.md b/README.md index 66459cd24..b41507c02 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,12 @@ npm run build:clean:stage :warning: Note: This will promote the contents of your local public directory. Your instance in staging may break or be outdated if you haven't run `npm run build` before `make stage`. +## Staging with Netlify + +When a commit is pushed, this automatically triggers a Netlify build on your branch. For every push, a deploy and deploy preview will be generated. + +By default, the master branch of `docs-landing` will be parsed with the parser version specified in the `Netlify.toml` and built using your branch as the frontend. If you'd like to build a different site or branch or build with a different parser version, this can be easily done by just updating the values in the Netlify.toml accordingly. Don't forget to update the `ORG_NAME` to `mongodb` or `10gen` depending on which org your repo belongs to! + ## Releasing We have configured an automatic release process using [GitHub Actions](https://github.com/features/actions) that is triggered by [npm-version](https://docs.npmjs.com/cli/version). To release a version, you must have admin privileges in this repo. Then proceed as follows: diff --git a/build.sh b/build.sh index acedec667..61b9f8404 100644 --- a/build.sh +++ b/build.sh @@ -1,21 +1,23 @@ # variables that need to be changed based on the content repo you're working on ------------------------------------------- -TESTING_CONTENT_REPO=docs-landing # name of content repo -ORGANIZATION=mongodb # name of org, usually mongodb or 10gen +TESTING_ORGANIZATION=$1 # name of org, usually mongodb or 10gen +TESTING_REPO_NAME=$2 # name of content repo +TESTING_BRANCH_NAME=$3 # name of the branch +PARSER_VERSION=$4 # version of the parser to download # ------------------------------------------------------------------------------------------------------------------------- -PARSER_VERSION=0.18.6 # 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 - we don't need this for docs-landing, but have it here for when we change repos # cloning the content repo -echo "cloning content repo: ${TESTING_CONTENT_REPO}" -git clone https://github.com/${ORGANIZATION}/${TESTING_CONTENT_REPO}.git +echo "Cloning content repo: ${TESTING_REPO_NAME}" +git clone -b ${TESTING_BRANCH_NAME} https://github.com/${TESTING_ORGANIZATION}/${TESTING_REPO_NAME}.git + # running the parser if [ ! -d "snooty-parser" ]; then - echo "snooty parser not installed, downloading..." + echo "Snooty parser not installed, downloading parser version $PARSER_VERSION ..." 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 @@ -23,7 +25,7 @@ fi echo "=======================================================================================================================================================================" echo "========================================================================== Running parser... ==========================================================================" -./snooty-parser/snooty/snooty build $(pwd)/${TESTING_CONTENT_REPO} --output=./bundle.zip +./snooty-parser/snooty/snooty build $(pwd)/${TESTING_REPO_NAME} --output=./bundle.zip echo "========================================================================== Parser complete ============================================================================" echo "=======================================================================================================================================================================" diff --git a/netlify.toml b/netlify.toml index 937e9fc6a..3a4ac8875 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,4 +3,10 @@ name = "snooty-cache-plugin" [build] publish = "public" -command = ". ./build.sh" +command = ". ./build.sh $ORG_NAME $REPO_NAME $BRANCH_NAME $PARSER_VERSION" + +[build.environment] +ORG_NAME = "mongodb" +REPO_NAME = "docs-landing" +BRANCH_NAME = "master" +PARSER_VERSION = "0.18.6" \ No newline at end of file