43 lines
1.1 KiB
YAML
43 lines
1.1 KiB
YAML
name: Deploy to Server
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: alpine:latest
|
|
steps:
|
|
- name: Install SSH and Networking Tools
|
|
run: apk add --no-cache openssh-client iproute2 git
|
|
|
|
- name: Configure SSH Key
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
echo "StrictHostKeyChecking no" > ~/.ssh/config
|
|
|
|
- name: Execute Remote Deployment
|
|
run: |
|
|
HOST_IP=$(ip route | awk '/default/ { print $3 }')
|
|
echo "==> Detected Host IP: $HOST_IP"
|
|
|
|
ssh adipu@$HOST_IP << 'EOF'
|
|
set -e
|
|
echo "==> Navigating to project directory..."
|
|
cd ~/SousChefAI
|
|
echo "==> Pulling latest code..."
|
|
git pull origin main
|
|
|
|
echo "==> Building and starting container..."
|
|
docker-compose up -d --build
|
|
|
|
echo "==> Pruning old images..."
|
|
docker image prune -f
|
|
echo "==> Deployment Complete!"
|
|
EOF
|