#!/bin/bash

# Flows
source ./flows/base
source ./flows/git
source ./flows/kube
source ./flows/packaging

# Vars
BUILD_DIRECTORY="web"
GITEA_ORGANIZATION="agreego"
GITEA_REPOSITORY="site"

build() {
  # Create build directory if it doesn't exist
  mkdir -p "$PACKAGE_DIRECTORY"
  # Get version
  version=$(get-version) || exit $?
  info "Building site version v$version..."
  COPYFILE_DISABLE=1 tar -czf "$PACKAGE_DIRECTORY/$GITEA_REPOSITORY.tar.gz" -C "$BUILD_DIRECTORY" . || abort "Failed to create tarball" 2
  success "Build complete" && return 0
}

site-usage() {
  echo "build|Build the site."
}

site-flow() {
  case "$1" in
    build) build; return $?;;
    *) return 127 ;;
  esac
}

register-flow "site"
dispatch "$@"