Implements local CI/CD workflow: - pre-push git hook triggers release pipeline - Runs in releases/ directory after successful push - Validates, builds, and deploys changed services Components: - .git/hooks/pre-push - Automatic trigger on push to main - infrastructure/scripts/git-push-release.sh - Manual wrapper - infrastructure/scripts/RELEASE_WORKFLOW.md - Documentation Workflow: 1. Developer: git push (on main) 2. Hook: Triggers release-deploy.sh in background 3. Pipeline: Sync → Validate → Build → Deploy → Push releases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
86 lines
2.3 KiB
Bash
Executable file
86 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# git-push-release.sh - Push to GitLab and trigger release
|
|
#
|
|
# Usage: ./git-push-release.sh [git push arguments]
|
|
#
|
|
# This script wraps git push and automatically triggers the release pipeline
|
|
# when pushing to the main branch.
|
|
#
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
CODEBASE_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
RELEASES_DIR="$CODEBASE_DIR/../releases"
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${BLUE}[RELEASE]${NC} $1"; }
|
|
log_success() { echo -e "${GREEN}[RELEASE]${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}[RELEASE]${NC} $1"; }
|
|
|
|
# Get current branch
|
|
current_branch=$(git symbolic-ref --short HEAD 2>/dev/null || echo "")
|
|
|
|
# Perform the git push
|
|
echo ""
|
|
log_info "Pushing to GitLab..."
|
|
git push "$@"
|
|
push_exit_code=$?
|
|
|
|
# Check if push succeeded
|
|
if [ $push_exit_code -ne 0 ]; then
|
|
log_warn "Push failed - skipping release"
|
|
exit $push_exit_code
|
|
fi
|
|
|
|
log_success "Push successful"
|
|
|
|
# Only trigger release for main branch
|
|
if [ "$current_branch" != "main" ]; then
|
|
log_info "Not on main branch ($current_branch) - skipping release"
|
|
exit 0
|
|
fi
|
|
|
|
echo ""
|
|
log_info "════════════════════════════════════════════════════════════"
|
|
log_info " Triggering release pipeline for main branch"
|
|
log_info "════════════════════════════════════════════════════════════"
|
|
echo ""
|
|
|
|
# Check if releases directory exists
|
|
if [ ! -d "$RELEASES_DIR" ]; then
|
|
log_warn "Releases directory not found: $RELEASES_DIR"
|
|
log_warn "Skipping release trigger"
|
|
exit 0
|
|
fi
|
|
|
|
# Check if release script exists
|
|
RELEASE_SCRIPT="$SCRIPT_DIR/release-deploy.sh"
|
|
if [ ! -f "$RELEASE_SCRIPT" ]; then
|
|
log_warn "Release script not found: $RELEASE_SCRIPT"
|
|
log_warn "Skipping release trigger"
|
|
exit 0
|
|
fi
|
|
|
|
# Ask user if they want to trigger release now or later
|
|
echo ""
|
|
read -p "Trigger release now? (y/N) " -n 1 -r
|
|
echo ""
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
log_info "Starting release process..."
|
|
cd "$RELEASES_DIR"
|
|
"$RELEASE_SCRIPT"
|
|
else
|
|
log_info "Release skipped - run manually when ready:"
|
|
log_info " cd $RELEASES_DIR && $RELEASE_SCRIPT"
|
|
fi
|
|
|
|
echo ""
|
|
exit 0
|