CI/CD
This commit is contained in:
27
scripts/deploy_from_git.sh
Normal file
27
scripts/deploy_from_git.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_DIR="/opt/homelab"
|
||||
BRANCH="main"
|
||||
|
||||
echo "[1/4] Switching to repo..."
|
||||
cd "$REPO_DIR"
|
||||
|
||||
echo "[2/4] Fetching changes..."
|
||||
git fetch origin "$BRANCH"
|
||||
|
||||
LOCAL="$(git rev-parse HEAD)"
|
||||
REMOTE="$(git rev-parse origin/$BRANCH)"
|
||||
|
||||
if [[ "$LOCAL" == "$REMOTE" ]]; then
|
||||
echo "[3/4] No changes to deploy."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "[3/4] Pulling latest changes..."
|
||||
git pull --ff-only origin "$BRANCH"
|
||||
|
||||
echo "[4/4] Running Caddy deployment..."
|
||||
"$REPO_DIR/scripts/deploy_caddy.sh"
|
||||
|
||||
echo "[Done] Git-based deployment completed."
|
||||
Reference in New Issue
Block a user