diff --git a/.travis.yml b/.travis.yml index 252d8cef98..f55d1afaff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -109,7 +109,7 @@ jobs: # docs pull request - name: "docs" - if: type IN (push, pull_request) + if: type IN (push, pull_request) OR tag IS present language: node_js node_js: - "node" diff --git a/docs/.gitignore b/docs/.gitignore index dfd0740615..62a6ce240d 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -9,6 +9,7 @@ .cache-loader .vercel /static/img/*.svg +vercel.json # Misc .DS_Store diff --git a/docs/README.md b/docs/README.md index b3a0bdb370..7ca3921502 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,7 +3,7 @@ Solana's Docs are built using [Docusaurus 2](https://v2.docusaurus.io/) with `npm`. Static content delivery is handled using `vercel`. -### Installation +### Installing Docusaurus ``` $ npm install @@ -11,22 +11,23 @@ $ npm install ### Local Development +This command starts a local development server and open up a browser window. +Most changes are reflected live without having to restart the server. + ``` $ npm run start ``` -This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server. - -### Build -#### Local Build Testing -``` -$ npm run build -``` +### Build Locally This command generates static content into the `build` directory and can be served using any static contents hosting service. -#### CI Build Flow +``` +$ docs/build.sh +``` + +### CI Build Flow The docs are built and published in Travis CI with the `docs/build.sh` script. On each PR, the docs are built, but not published. diff --git a/docs/build.sh b/docs/build.sh index a19c45cd02..2c66ca30d5 100755 --- a/docs/build.sh +++ b/docs/build.sh @@ -26,20 +26,9 @@ source ../ci/rust-version.sh # Build from /src into /build npm run build -# Deploy the /build content using vercel -if [[ -d .vercel ]]; then - rm -r .vercel -fi -./set-vercel-project-name.sh - +# Publish only from merge commits and release tags if [[ -n $CI ]]; then if [[ -z $CI_PULL_REQUEST ]]; then - [[ -n $VERCEL_TOKEN ]] || { - echo "VERCEL_TOKEN is undefined. Needed for Vercel authentication." - exit 1 - } - vercel deploy . --local-config=vercel.json --confirm --token "$VERCEL_TOKEN" --prod + ./publish-docs.sh fi -else - vercel deploy . --local-config=vercel.json fi diff --git a/docs/publish-docs.sh b/docs/publish-docs.sh new file mode 100755 index 0000000000..11a51aff1f --- /dev/null +++ b/docs/publish-docs.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -e + +if [[ -d .vercel ]]; then + rm -r .vercel +fi + +CONFIG_FILE=vercel.json + +if [[ -n $CI_TAG ]]; then + PROJECT_NAME=docs-solana-com +else + eval "$(../ci/channel-info.sh)" + case $CHANNEL in + edge) + PROJECT_NAME=edge-docs-solana-com + ;; + beta) + PROJECT_NAME=beta-docs-solana-com + ;; + *) + PROJECT_NAME=docs + ;; + esac +fi + +cat > "$CONFIG_FILE" <