Clean up docs publishing flow (#11043)

* Clean up publishing flow

* Update README

Co-authored-by: publish-docs.sh <maintainers@solana.com>
This commit is contained in:
Dan Albert
2020-07-14 07:56:14 -06:00
committed by GitHub
parent 14ac233d01
commit 303a4df6ef
7 changed files with 53 additions and 52 deletions

View File

@ -109,7 +109,7 @@ jobs:
# docs pull request # docs pull request
- name: "docs" - name: "docs"
if: type IN (push, pull_request) if: type IN (push, pull_request) OR tag IS present
language: node_js language: node_js
node_js: node_js:
- "node" - "node"

1
docs/.gitignore vendored
View File

@ -9,6 +9,7 @@
.cache-loader .cache-loader
.vercel .vercel
/static/img/*.svg /static/img/*.svg
vercel.json
# Misc # Misc
.DS_Store .DS_Store

View File

@ -3,7 +3,7 @@
Solana's Docs are built using [Docusaurus 2](https://v2.docusaurus.io/) with `npm`. Solana's Docs are built using [Docusaurus 2](https://v2.docusaurus.io/) with `npm`.
Static content delivery is handled using `vercel`. Static content delivery is handled using `vercel`.
### Installation ### Installing Docusaurus
``` ```
$ npm install $ npm install
@ -11,22 +11,23 @@ $ npm install
### Local Development ### 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 $ 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 Locally
### Build
#### Local Build Testing
```
$ npm run build
```
This command generates static content into the `build` directory and can be This command generates static content into the `build` directory and can be
served using any static contents hosting service. 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. 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. On each PR, the docs are built, but not published.

View File

@ -26,20 +26,9 @@ source ../ci/rust-version.sh
# Build from /src into /build # Build from /src into /build
npm run build npm run build
# Deploy the /build content using vercel # Publish only from merge commits and release tags
if [[ -d .vercel ]]; then
rm -r .vercel
fi
./set-vercel-project-name.sh
if [[ -n $CI ]]; then if [[ -n $CI ]]; then
if [[ -z $CI_PULL_REQUEST ]]; then if [[ -z $CI_PULL_REQUEST ]]; then
[[ -n $VERCEL_TOKEN ]] || { ./publish-docs.sh
echo "VERCEL_TOKEN is undefined. Needed for Vercel authentication."
exit 1
}
vercel deploy . --local-config=vercel.json --confirm --token "$VERCEL_TOKEN" --prod
fi fi
else
vercel deploy . --local-config=vercel.json
fi fi

39
docs/publish-docs.sh Executable file
View File

@ -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" <<EOF
{
"name": "$PROJECT_NAME",
"scope": "solana-labs"
}
EOF
[[ -n $VERCEL_TOKEN ]] || {
echo "VERCEL_TOKEN is undefined. Needed for Vercel authentication."
exit 1
}
vercel deploy . --local-config="$CONFIG_FILE" --confirm --token "$VERCEL_TOKEN" --prod

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
# Replaces the PROJECT_NAME value in vercel.json commit based on channel or tag
# so we push the updated docs to the right domain
set -e
if [[ -n $CI_TAG ]]; then
NAME=docs-solana-com
else
eval "$(../ci/channel-info.sh)"
case $CHANNEL in
edge)
NAME=edge-docs-solana-com
;;
beta)
NAME=beta-docs-solana-com
;;
*)
NAME=docs
;;
esac
fi
sed -i s/PROJECT_NAME/$NAME/g vercel.json

View File

@ -1,4 +0,0 @@
{
"name": "PROJECT_NAME",
"scope": "solana-labs"
}