> ## 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_dashboard_app.sh

> Push the hosted dashboard's files to the repository Streamlit Community Cloud deploys from (decision 0013). The hosted app is src/dashboard/app.py itself, with only the code it imports, the config/ lists and the recorded snapshot; nothing with prices.

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

## What it does

Push the hosted dashboard's files to the repository Streamlit Community Cloud deploys from
(decision 0013). The hosted app is src/dashboard/app.py itself, with only the code it imports,
the config/ lists and the recorded snapshot; nothing with prices.

The address comes from: git config calendar-effects.dashboardRemote, which scripts/install\_git\_hooks.sh
sets to the team's dashboard repository (github.com/Calendar-Effects/dashboard) and runs this after
each commit:   scripts/sync\_dashboard\_app.sh
Without the setting it does nothing. An https address signs in with the GitHub CLI.

## Source

```bash title="scripts/sync_dashboard_app.sh" lines expandable theme={null}
#!/usr/bin/env bash
# Push the hosted dashboard's files to the repository Streamlit Community Cloud deploys from
# (decision 0013). The hosted app is src/dashboard/app.py itself, with only the code it imports,
# the config/ lists and the recorded snapshot; nothing with prices.
#
# The address comes from: git config calendar-effects.dashboardRemote, which scripts/install_git_hooks.sh
# sets to the team's dashboard repository (github.com/Calendar-Effects/dashboard) and runs this after
# each commit:   scripts/sync_dashboard_app.sh
# Without the setting it does nothing. An https address signs in with the GitHub CLI.
set -euo pipefail

root=$(git rev-parse --show-toplevel)

# The hosted app's files: only the code it imports, config/, the recording, and its settings.
bundle() {
  local dest="$1"
  find "$dest" -mindepth 1 -maxdepth 1 ! -name .git ! -name .github -exec rm -rf {} +   # .github: its own workflow
  mkdir -p "$dest/src/hosting" "$dest/hosting" "$dest/.streamlit"
  cp -R "$root/src/common" "$root/src/dashboard" "$dest/src/"
  cp "$root/src/hosting/__init__.py" "$root/src/hosting/live.py" "$dest/src/hosting/"
  cp -R "$root/config" "$dest/config"
  cp -R "$root/hosting/snapshot" "$dest/hosting/snapshot"
  cp "$root/pyproject.toml" "$dest/"
  cp "$root/hosting/streamlit/requirements.txt" "$root/hosting/streamlit/README.md" "$dest/"
  cp "$root/hosting/streamlit/config.toml" "$dest/.streamlit/config.toml"
  find "$dest" -name __pycache__ -type d -prune -exec rm -rf {} +
}

# --into DIR: only write the files into DIR.
if [ "${1:-}" = "--into" ]; then
  bundle "$2"
  exit 0
fi

branch=$(git -C "$root" rev-parse --abbrev-ref HEAD)
if [ "$branch" != "main" ]; then          # only main is published; branches wait for their merge
  echo "dashboard: on branch $branch, not main; nothing published."
  exit 0
fi
remote=$(git -C "$root" config --get calendar-effects.dashboardRemote || true)
if [ -z "$remote" ]; then
  echo "dashboard: no calendar-effects.dashboardRemote set, nothing to push (see scripts/sync_dashboard_app.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)/dashboard-app-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

# Start from an empty tree each time, so files removed here disappear there too.
bundle "$cache"

git -C "$cache" add -A
if git -C "$cache" diff --cached --quiet; then
  echo "dashboard: already up to date."
  exit 0
fi
git -C "$cache" commit -q -m "Sync dashboard from $(git -C "$root" rev-parse --short HEAD)"
g -C "$cache" push -q origin HEAD:main
echo "dashboard: pushed; Streamlit Community Cloud redeploys in a minute or two."
```


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