#!/usr/bin/env bash
# A simple shell script with functions and error handling
set -euo pipefail

deploy() {
    local env="${1:-staging}"
    local tag
    tag=$(git rev-parse --short HEAD)

    echo "Deploying ${tag} to ${env}..."
    if docker build -t "app:${tag}" . && docker push "app:${tag}"; then
        echo "✓ Published app:${tag}"
    else
        echo "✗ Build/push failed" >&2
        return 1
    fi
}

deploy "$@"
