ci: clone/pull repo
This commit is contained in:
@@ -51,6 +51,10 @@ jobs:
|
|||||||
echo "Action: ${{ inputs.action }}"
|
echo "Action: ${{ inputs.action }}"
|
||||||
echo "Detached: ${{ inputs.detach }}"
|
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
|
# Server-Konfiguration setzen
|
||||||
case "${{ inputs.server }}" in
|
case "${{ inputs.server }}" in
|
||||||
devops)
|
devops)
|
||||||
@@ -103,8 +107,23 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "=== Deploying to ${{ inputs.server }} ==="
|
echo "=== Deploying to ${{ inputs.server }} ==="
|
||||||
|
|
||||||
# Git pull auf dem Server
|
# Check ob Repo existiert, sonst clonen
|
||||||
ssh $USER@$HOST "git pull"
|
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
|
# Docker Compose Aktion ausführen
|
||||||
case "${{ inputs.action }}" in
|
case "${{ inputs.action }}" in
|
||||||
@@ -143,8 +162,23 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
echo ">>> Deploying to $server..."
|
echo ">>> Deploying to $server..."
|
||||||
|
|
||||||
# Git pull
|
# Check ob Repo existiert, sonst clonen
|
||||||
ssh $user_host "cd $compose_path && git pull" || { echo "Failed to deploy to $server"; continue; }
|
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
|
# Docker Compose Aktion
|
||||||
case "${{ inputs.action }}" in
|
case "${{ inputs.action }}" in
|
||||||
|
|||||||
Reference in New Issue
Block a user