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

> Copy what the cloud streamer runs into the `project` branch of the team's private live-stream repository on github.com (decision 0015), so its workflow needs no access to github.sfu.ca. The copy is only what scripts/demo_live.sh needs: src/, config/, clean/master.parquet (the replay's input), the de

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

## What it does

Copy what the cloud streamer runs into the `project` branch of the team's private live-stream
repository on github.com (decision 0015), so its workflow needs no access to github.sfu.ca.
The copy is only what scripts/demo\_live.sh needs: src/, config/, clean/master.parquet (the replay's
input), the demo script, requirements.txt and pyproject.toml. The model comes from Hugging Face.

Runs after each commit on main (scripts/install\_git\_hooks.sh), like the docs and dashboard syncs.
The address comes from: git config calendar-effects.streamerRemote (the installer sets it).
Without it, it does nothing. An https address signs in with the GitHub CLI (gh auth login).
scripts/sync\_live\_stream.sh              copy and push (main only)
scripts/sync\_live\_stream.sh --into DIR   only write the files into DIR (the tests use this)

## Source

```bash title="scripts/sync_live_stream.sh" lines expandable theme={null}
#!/usr/bin/env bash
# Copy what the cloud streamer runs into the `project` branch of the team's private live-stream
# repository on github.com (decision 0015), so its workflow needs no access to github.sfu.ca.
# The copy is only what scripts/demo_live.sh needs: src/, config/, clean/master.parquet (the replay's
# input), the demo script, requirements.txt and pyproject.toml. The model comes from Hugging Face.
#
# Runs after each commit on main (scripts/install_git_hooks.sh), like the docs and dashboard syncs.
# The address comes from: git config calendar-effects.streamerRemote (the installer sets it).
# Without it, it does nothing. An https address signs in with the GitHub CLI (gh auth login).
#   scripts/sync_live_stream.sh              copy and push (main only)
#   scripts/sync_live_stream.sh --into DIR   only write the files into DIR (the tests use this)
set -euo pipefail

root=$(cd "$(dirname "$0")/.." && pwd)
FILES=(src config clean/master.parquet scripts/demo_live.sh requirements.txt pyproject.toml)
BRANCH=project

bundle() {  # write the files the streamer needs into $1, as committed (as on disk without git)
  local dest="$1"
  find "$dest" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
  if git -C "$root" rev-parse --verify -q HEAD >/dev/null 2>&1; then
    git -C "$root" archive HEAD "${FILES[@]}" | tar -x -C "$dest"
  else
    for f in "${FILES[@]}"; do mkdir -p "$dest/$(dirname "$f")"; cp -R "$root/$f" "$dest/$f"; done
  fi
  find "$dest" -name __pycache__ -type d -prune -exec rm -rf {} +
}

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 copied; branches wait for their merge
  echo "live stream: on branch $branch, not main; nothing copied."
  exit 0
fi
remote=$(git -C "$root" config --get calendar-effects.streamerRemote || true)
if [ -z "$remote" ]; then
  echo "live stream: no calendar-effects.streamerRemote set, nothing to push (scripts/install_git_hooks.sh sets it)."
  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)/live-stream-sync"
case "$cache" in /*) ;; *) cache="$root/$cache" ;; esac
if [ ! -d "$cache/.git" ]; then
  rm -rf "$cache"
  git init -q "$cache"
  git -C "$cache" remote add origin "$remote"
fi
if g -C "$cache" fetch -q origin "$BRANCH" 2>/dev/null; then
  git -C "$cache" checkout -q -B "$BRANCH" FETCH_HEAD
else                                      # the first copy: a new branch with no history
  git -C "$cache" checkout -q --orphan "$BRANCH" 2>/dev/null || true
fi

bundle "$cache"
git -C "$cache" add -A
if git -C "$cache" diff --cached --quiet; then
  echo "live stream: already up to date."
  exit 0
fi
git -C "$cache" commit -q -m "Copy the project from $(git -C "$root" rev-parse --short HEAD)"
g -C "$cache" push -q origin "HEAD:refs/heads/$BRANCH"
echo "live stream: pushed the project copy; the next Live stream run uses it."
```


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