> ## Documentation Index
> Fetch the complete documentation index at: https://calendar-effects.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# scripts/sync_docs_site.sh

> Push docs-site/ to the docs repository Mintlify deploys from (decision 0011).

`scripts/sync_docs_site.sh` · chapter [Tests and team tooling](https://calendar-effects.mintlify.site/tour/10-tests-and-tooling.md), file 24 · 54 lines · [open in the repository](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/scripts/sync_docs_site.sh)

## What it does

Push docs-site/ to the docs repository Mintlify deploys from (decision 0011).

Mintlify cannot read github.sfu.ca on its free plan, so the site lives in a small separate
repository on github.com that Mintlify watches; every push there redeploys the site.
This script copies docs-site/ into a cached clone of that repository and pushes it.

The address comes from: git config calendar-effects.docsRemote, which scripts/install\_git\_hooks.sh
sets to the team's docs repository (github.com/Calendar-Effects/docs) and runs this after each
commit. An https address signs in with the GitHub CLI (`gh auth login`) if it is installed; an ssh
address ([git@github.com](mailto:git@github.com):...) needs an SSH key registered on github.com.
scripts/sync\_docs\_site.sh
Without the setting it does nothing, so teammates who do not publish are not affected.

## Source

```bash title="scripts/sync_docs_site.sh" lines expandable theme={null}
#!/usr/bin/env bash
# Push docs-site/ to the docs repository Mintlify deploys from (decision 0011).
#
# Mintlify cannot read github.sfu.ca on its free plan, so the site lives in a small separate
# repository on github.com that Mintlify watches; every push there redeploys the site.
# This script copies docs-site/ into a cached clone of that repository and pushes it.
#
# The address comes from: git config calendar-effects.docsRemote, which scripts/install_git_hooks.sh
# sets to the team's docs repository (github.com/Calendar-Effects/docs) and runs this after each
# commit. An https address signs in with the GitHub CLI (`gh auth login`) if it is installed; an ssh
# address (git@github.com:...) needs an SSH key registered on github.com.
#   scripts/sync_docs_site.sh
# Without the setting it does nothing, so teammates who do not publish are not affected.
set -euo pipefail

root=$(git rev-parse --show-toplevel)
branch=$(git -C "$root" rev-parse --abbrev-ref HEAD)
if [ "$branch" != "main" ]; then          # only main is published; branches wait for their merge
  echo "docs site: on branch $branch, not main; nothing published."
  exit 0
fi
remote=$(git -C "$root" config --get calendar-effects.docsRemote || true)
if [ -z "$remote" ]; then
  echo "docs site: no calendar-effects.docsRemote set, nothing to push (see scripts/sync_docs_site.sh)."
  exit 0
fi

g() {  # git, signing in to https remotes with the GitHub CLI when it is available
  if command -v gh >/dev/null 2>&1 && [[ "$remote" == https://* ]]; then
    git -c credential.helper= -c 'credential.helper=!gh auth git-credential' "$@"
  else
    git "$@"
  fi
}

cache="$(git -C "$root" rev-parse --git-common-dir)/docs-site-sync"
case "$cache" in /*) ;; *) cache="$root/$cache" ;; esac
if [ ! -d "$cache/.git" ]; then
  rm -rf "$cache"
  g clone -q "$remote" "$cache" 2>/dev/null || { git init -q -b main "$cache"; git -C "$cache" remote add origin "$remote"; }
fi
if g -C "$cache" fetch -q origin main 2>/dev/null; then
  git -C "$cache" checkout -q -B main origin/main
fi

rsync -a --delete --exclude .git --exclude .github "$root/docs-site/" "$cache/"   # .github: its own workflow
git -C "$cache" add -A
if git -C "$cache" diff --cached --quiet; then
  echo "docs site: already up to date."
  exit 0
fi
git -C "$cache" commit -q -m "Sync docs-site from $(git -C "$root" rev-parse --short HEAD)"
g -C "$cache" push -q origin HEAD:main
echo "docs site: pushed; Mintlify redeploys in a minute or two."
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.