Sha256: c39e847abf13a852aff9d3e9bebcbb780a923d79a132782cbd283aa5ec01766b

Contents?: true

Size: 1.96 KB

Versions: 11

Compression:

Stored size: 1.96 KB

Contents

#!/bin/bash
#
# this hook runs giblish on a document tree according to the 
# users settings.
# Typically used to publish html documents when a push to a matching
# branch is detected.

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

# the relative path to a subfolder in the repo where the docs are
REPO_DOC_SUBFOLDER="docs"

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

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

# path to a top dir of the styling css and other resources
RESOURCE_DIR="scripts/resources"

# the name of the css file to use for styling, without the 'css' extension
LAYOUT_STYLE="giblish"

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

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
  echo "running giblish..."
  giblish -a xrefstyle=basic \
          --copy-asset-folders "_assets$" \
          -g "${TRIGGERING_REFS_REGEX}" \
          -r "${RESOURCE_DIR}" \
          -s "${LAYOUT_STYLE}" \
          "${REPO_DOC_SUBFOLDER}" "${DST_DIR}"
)

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
giblish-2.2.2 scripts/hooks/post-receive.example
giblish-2.2.1 scripts/hooks/post-receive.example
giblish-2.2.0 scripts/hooks/post-receive.example
giblish-2.1.2 scripts/hooks/post-receive.example
giblish-2.1.1 scripts/hooks/post-receive.example
giblish-2.1.0 scripts/hooks/post-receive.example
giblish-2.0.1 scripts/hooks/post-receive.example
giblish-2.0.0 scripts/hooks/post-receive.example
giblish-2.0.0.pre.alpha1 scripts/hooks/post-receive.example
giblish-1.0.0 scripts/hooks/post-receive.example
giblish-1.0.0.rc2 scripts/hooks/post-receive.example