ci: clone/pull repo
This commit is contained in:
@@ -51,6 +51,10 @@ jobs:
|
||||
echo "Action: ${{ inputs.action }}"
|
||||
echo "Detached: ${{ inputs.detach }}"
|
||||
|
||||
# Git Repo URL (aus Gitea)
|
||||
REPO_URL="https://git.hashdot.co/${{ github.repository }}.git"
|
||||
echo "REPO_URL=$REPO_URL" >> $GITHUB_ENV
|
||||
|
||||
# Server-Konfiguration setzen
|
||||
case "${{ inputs.server }}" in
|
||||
devops)
|
||||
@@ -103,8 +107,23 @@ jobs:
|
||||
run: |
|
||||
echo "=== Deploying to ${{ inputs.server }} ==="
|
||||
|
||||
# Git pull auf dem Server
|
||||
ssh $USER@$HOST "git pull"
|
||||
# Check ob Repo existiert, sonst clonen
|
||||
ssh $USER@$HOST "
|
||||
export COMPOSE_PATH='$COMPOSE_PATH'
|
||||
export REPO_URL='$REPO_URL'
|
||||
|
||||
if [ -d \"\$COMPOSE_PATH/.git\" ]; then
|
||||
echo 'Repository already exists, pulling latest changes...'
|
||||
cd \$COMPOSE_PATH && git pull
|
||||
else
|
||||
echo 'Repository not found, cloning...'
|
||||
PARENT_DIR=\$(dirname \$COMPOSE_PATH)
|
||||
mkdir -p \$PARENT_DIR
|
||||
cd \$PARENT_DIR
|
||||
git clone \$REPO_URL \$(basename \$COMPOSE_PATH)
|
||||
echo 'Repository cloned successfully'
|
||||
fi
|
||||
"
|
||||
|
||||
# Docker Compose Aktion ausführen
|
||||
case "${{ inputs.action }}" in
|
||||
@@ -143,8 +162,23 @@ jobs:
|
||||
echo ""
|
||||
echo ">>> Deploying to $server..."
|
||||
|
||||
# Git pull
|
||||
ssh $user_host "cd $compose_path && git pull" || { echo "Failed to deploy to $server"; continue; }
|
||||
# Check ob Repo existiert, sonst clonen
|
||||
ssh $user_host "
|
||||
export COMPOSE_PATH='$compose_path'
|
||||
export REPO_URL='$REPO_URL'
|
||||
|
||||
if [ -d \"\$COMPOSE_PATH/.git\" ]; then
|
||||
echo 'Repository already exists, pulling latest changes...'
|
||||
cd \$COMPOSE_PATH && git pull
|
||||
else
|
||||
echo 'Repository not found, cloning...'
|
||||
PARENT_DIR=\$(dirname \$COMPOSE_PATH)
|
||||
mkdir -p \$PARENT_DIR
|
||||
cd \$PARENT_DIR
|
||||
git clone \$REPO_URL \$(basename \$COMPOSE_PATH)
|
||||
echo 'Repository cloned successfully'
|
||||
fi
|
||||
" || { echo "Failed to setup git for $server"; continue; }
|
||||
|
||||
# Docker Compose Aktion
|
||||
case "${{ inputs.action }}" in
|
||||
|
||||
Reference in New Issue
Block a user