Sfoglia il codice sorgente

First stab at setting up CI for docs

Christopher Mullins 6 anni fa
parent
commit
91696d5e3f
3 ha cambiato i file con 58 aggiunte e 10 eliminazioni
  1. 1 0
      .gitignore
  2. 38 0
      .prepare_docs
  3. 19 10
      .travis.yml

+ 1 - 0
.gitignore

@@ -7,6 +7,7 @@
 /web/node_modules
 /web/build
 /dist/*.bin
+/dist/docs
 .vscode/
 .vscode/.browse.c_cpp.db*
 .vscode/c_cpp_properties.json

+ 38 - 0
.prepare_docs

@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+set -eo pipefail
+
+prepare_docs_log() {
+  echo "[prepare docs release] -- $@"
+}
+
+# Only run for tagged commits
+if [ -z "$(git tag -l --points-at HEAD)" ]; then
+  prepare_docs_log "Skipping non-tagged commit."
+  exit 0
+fi
+
+DOCS_DIR="./docs"
+DIST_DIR="./dist/docs"
+BRANCHES_DIR="${DIST_DIR}/branches"
+API_SPEC_FILE="${DOCS_DIR}/openapi.yaml"
+
+redoc_bundle_file=$(mktemp)
+git_ref_version=$(git describe --always)
+branch_docs_dir="${BRANCHES_DIR}/${git_ref_version}"
+
+# Build Redoc bundle (a single HTML file)
+redoc-cli bundle ${API_SPEC_FILE} -o ${redoc_bundle_file}
+
+# Check out current stuff from gh-pages (we'll append to it)
+git checkout gh-pages -- docs
+
+# Create the docs bundle for our ref.  This will be the redoc bundle + a
+# snapshot of the OpenAPI spec
+mkdir -p "${branch_docs_dir}"
+cp "${API_SPEC_FILE}" "${branch_docs_dir}"
+cp "${redoc_bundle_file}" "${branch_docs_dir}/index.html"
+
+# Create a JSON file containing a list of all branches with docs (we'll
+# have an index page that renders the list).
+ls "${BRANCHES_DIR}" | jq -R | jq -sc > "${DIST_DIR}/branches.json"

File diff suppressed because it is too large
+ 19 - 10
.travis.yml