#!/bin/bash

# Reschedule this job with:
# brun //pipedream/api:schedule -- --pipeline_file $(pwd)/pipedream/pipelines/doxygen_deploy.json --schedule '0 45 0 * * *'
#
# Usage: Run this script with no arguments to build all doxygen targets and upload them to docs.zooxlabs.com

set -euo pipefail
tmpdir=$(mktemp --directory)

(
  cd "$ZOOX_WORKSPACE_ROOT"
  docs=$(./ci/build_docs.sh)

  for doc in $docs; do
    tar --extract --file "$doc" --directory "$tmpdir"
  done

  aws s3 sync "$tmpdir" s3://zoox-web/$1 --delete
)
