#!/usr/bin/env sh
#
# One command to publish everything:
#   1. regenerate images.json from ./img
#   2. stage + commit the changes
#   3. push to the remote
#
# Usage:
#   ./pushAll
#
# Tip: make it a real command by adding this folder to your PATH, or create a
# git alias once with:  git config alias.pushAll '!./pushAll'
# then run it as:       git pushAll

set -e
cd "$(dirname "$0")"

# 1 + 2: rebuild the manifest and commit (handled by the Python script).
./generate-manifest.py

# 3: push, setting the upstream on first push.
if git rev-parse --abbrev-ref --symbolic-full-name '@{u}' >/dev/null 2>&1; then
    git push
else
    git push -u origin HEAD
fi
