github.com/m3db/m3@v1.5.0/scripts/site-build.sh (about)

     1  #!/usr/bin/env bash
     2  set -e
     3  HUGO_DOCKER_IMAGE="klakegg/hugo:ext-alpine"
     4  ASSET_DIR=${1:-src/query/generated/assets/openapi}
     5  
     6  # First generate old versions
     7  DOCS_VERSIONS=$(git tag -l 'docs/*')
     8  
     9  # Now generate latest
    10  # Copy over OpenAPI doc.
    11  mkdir -p site/static/openapi
    12  rsync -a --exclude=*.go "$ASSET_DIR"/* site/static/openapi
    13  # Create .bak file and then delete it to make sed work for both GNU and Mac versions
    14  sed -i.bak "s#spec-url='.*'#spec-url='spec.yml'#g" site/static/openapi/index.html
    15  rm -f site/static/openapi/index.html.bak
    16  
    17  # Now run hugo
    18  if [[ -n "${HUGO_DOCKER:-}" ]]; then
    19          docker run -e HUGO_ENV=production -it -v "$PWD"/site:/src "${HUGO_DOCKER_IMAGE}"
    20  else
    21          cd site
    22          hugo -e production -v
    23          cd ..
    24  fi
    25  
    26  for docVersion in $DOCS_VERSIONS
    27  do
    28          # Add copies of all docs tags
    29          IFS='/'
    30          read -ra version <<< "$docVersion"
    31          echo "Building $docVersion"
    32          git archive --output "site/${version[1]}.zip" "$docVersion:site/" && unzip -d "site/${version[1]}" "site/${version[1]}.zip" && rm -f "site/${version[1]}.zip"
    33  
    34          # Now run hugo
    35          if [[ -n "${HUGO_DOCKER:-}" ]]; then
    36                  docker run -e HUGO_ENV=production -e HUGO_DESTINATION="public/${version[1]}" -it -v "$PWD/site/${version[1]}":/src "${HUGO_DOCKER_IMAGE}"
    37          else
    38                  cd "site/${version[1]}"
    39                  hugo -e production -v -d "../public/${version[1]}"
    40                  cd ../../
    41          fi        
    42  done