HH/build-and-push.sh
2026-04-19 10:53:12 +03:00

48 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -e
REGISTRY="gitea.tenhal.sa/marwan/hh"
TAG=${1:-staging}
echo "========================================"
echo " PX360 Build & Push"
echo " Tag: $REGISTRY:$TAG"
echo " $(date '+%Y-%m-%d %H:%M:%S')"
echo "========================================"
if ! docker login "$REGISTRY" 2>/dev/null; then
echo ""
echo "Login required. Enter your Gitea credentials:"
echo " Username: your Gitea username"
echo " Password: your Gitea token (Settings > Applications > Access Tokens)"
echo ""
docker login "$REGISTRY"
fi
echo ""
echo "[1/3] Building image..."
docker build -t "$REGISTRY:$TAG" .
SHORT_SHA=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
if [ "$SHORT_SHA" != "unknown" ]; then
docker tag "$REGISTRY:$TAG" "$REGISTRY:$SHORT_SHA"
echo " Also tagged: $REGISTRY:$SHORT_SHA"
fi
echo ""
echo "[2/3] Pushing to registry..."
docker push "$REGISTRY:$TAG"
if [ "$SHORT_SHA" != "unknown" ]; then
docker push "$REGISTRY:$SHORT_SHA"
fi
echo ""
echo "[3/3] Done!"
echo ""
echo "Images pushed:"
echo " $REGISTRY:$TAG"
[ "$SHORT_SHA" != "unknown" ] && echo " $REGISTRY:$SHORT_SHA"
echo ""
echo "Deploy to staging: ./deploy.staging.sh $TAG"
echo "Deploy to prod: ./deploy.prod.sh $TAG"