Sha256: 52718253705355ab276a4dca6df2a0895f9f47625c4a68978a903139f5088018

Contents?: true

Size: 1.48 KB

Versions: 11

Compression:

Stored size: 1.48 KB

Contents

#!/bin/bash
#
# this hook runs a script which, in turn, generates html documentation
# and publishes them to the given destination.
#

# the git refs that should trigger a doc generation at update
TRIGGERING_REFS_REGEX=$'main'

# the staging repo root (where the working tree exists)
STAGING_REPO="/usr/local/git_staging/myrepo_staging"

# The web-server top dir for the published documents
DST_DIR="/var/www/mysite/html/public/docs"

# "true" runs an 'rm -rf' of the destination dir before generating new htmls
CLEAR_DST="false"

echo "post-receive hook running..."

# read the input that git sends to this hook
read oldrev newrev ref

# remove the 'refs/heads/' prefix from the git ref
ref="${ref/refs\/heads\//}"

# filter out refs that are irrelevant for doc generation
if [[ ! "${ref}" =~ "${TRIGGERING_REFS_REGEX}" ]]; then
  echo "Ref '${ref}' received. Doing nothing: only refs matching the regex: /${TRIGGERING_REFS_REGEX}/ will trigger a doc generation."
  exit 0
fi

echo "Document generation triggered by an update to ${ref}."
echo ""

# use a subshell with the correct working dir for the actual doc generation
(
  cd "${STAGING_REPO}"

  # need to unset the GIT_DIR env set by the invoking hook for giblish to work correctly
  unset GIT_DIR

  if [[ "${CLEAR_DST}" -eq "true" ]]; then
    echo "Remove everything under ${DST_DIR}/"
    rm -rf ${DST_DIR}/*
  fi

  # Generate html docs
  giblish --copy-asset-folders "_assets$" -g "${TRIGGERING_REFS_REGEX}" -r scripts/resources -s mystyle . "${DST_DIR}"
)

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
giblish-2.2.2 docs/howtos/setup_static_site_assets/post-receive-example.sh
giblish-2.2.1 docs/howtos/setup_static_site_assets/post-receive-example.sh
giblish-2.2.0 docs/howtos/setup_static_site_assets/post-receive-example.sh
giblish-2.1.2 docs/howtos/setup_static_site_assets/post-receive-example.sh
giblish-2.1.1 docs/howtos/setup_static_site_assets/post-receive-example.sh
giblish-2.1.0 docs/howtos/setup_static_site_assets/post-receive-example.sh
giblish-2.0.1 docs/howtos/setup_static_site_assets/post-receive-example.sh
giblish-2.0.0 docs/howtos/setup_static_site_assets/post-receive-example.sh
giblish-2.0.0.pre.alpha1 docs/howtos/trigger_generation_im/post-receive-example.sh
giblish-1.0.0 docs/howtos/trigger_generation_im/post-receive-example.sh
giblish-1.0.0.rc2 docs/howtos/trigger_generation_im/post-receive-example.sh