Skip to content

Commit

Permalink
fix(devops): deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
apogiatzis committed Nov 21, 2024
1 parent 9f9c0c4 commit 1fce75e
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions .github/workflows/deploy_bot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
name: Deploy Bot

on:
push:
branches:
- main

jobs:
dump-env:
deploy:
runs-on: ubuntu-latest
environment: PROD

steps:
- name: Checkout Repository
uses: actions/checkout@v3
Expand All @@ -26,7 +23,7 @@ jobs:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
SSH_HOST: ${{ secrets.SSH_HOST }}
run: |
run: >
apt-get update && apt-get install -y sshpass
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no "$SSH_USER@$SSH_HOST" "mkdir -p ~/ovisbot"
Expand All @@ -35,23 +32,25 @@ jobs:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
SSH_HOST: ${{ secrets.SSH_HOST }}
run: |
sshpass -p "$SSH_PASSWORD" rsync -avz --exclude '.git' ./ "$SSH_USER@$SSH_HOST:~/ovisbot"
run: >
sshpass -p "$SSH_PASSWORD" rsync -avz --exclude '.git' ./
"$SSH_USER@$SSH_HOST:~/ovisbot"
- name: Deploy Application
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
SSH_HOST: ${{ secrets.SSH_HOST }}
run: |
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no "$SSH_USER@$SSH_HOST" << 'EOF'
cd ~/ovisbot
if [ -f docker-compose.yml ]; then
docker compose -f docker-compose.yml -f docker-compose.prod.yml down || true
docker compose -f docker-compose.yml -f docker-compose.prod.yml pull
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
else
echo "docker-compose.yml not found in the repository!"
exit 1
fi
EOF
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
SSH_HOST: ${{ secrets.SSH_HOST }}
run: >
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no
"$SSH_USER@$SSH_HOST" << 'EOF'
cd ~/ovisbot
if [ -f docker-compose.yml ]; then
docker compose -f docker-compose.yml -f docker-compose.prod.yml down || true
docker compose -f docker-compose.yml -f docker-compose.prod.yml pull
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
else
echo "docker-compose.yml not found in the repository!"
exit 1
fi
EOF

0 comments on commit 1fce75e

Please sign in to comment.