Skip to content

update workflow

update workflow #19

Workflow file for this run

name: Deploy and Run Bot
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Deploy to Oracle VM
uses: appleboy/[email protected]
with:
host: ${{ secrets.ORACLE_HOST }}
username: ${{ secrets.ORACLE_USER }}
key: ${{ secrets.ORACLE_SSH_KEY }}
script: |
echo "Checking if the repository exists..."
if [ ! -d "/home/ubuntu/xtwitter_bot/.git" ]; then
echo "Repository does not exist. Cloning..."
git clone https://${{ secrets.FINEGRAINTOKEN }}@github.com/donneypr/xphilosphy_bot.git /home/ubuntu/xtwitter_bot
else
echo "Repository exists. Updating remote URL to use HTTPS..."
cd /home/ubuntu/xtwitter_bot
git remote set-url origin https://${{ secrets.FINEGRAINTOKEN }}@github.com/donneypr/xphilosphy_bot.git
git reset --hard # Discard local changes
git pull origin main || echo "Git pull failed"
fi
echo "Activating virtual environment..."
cd /home/ubuntu/xtwitter_bot
source venv/bin/activate
echo "Restarting bot in a screen session..."
screen -ls | grep "phil_bot" && screen -S phil_bot -X quit || true
screen -dmS phil_bot venv/bin/python3 xtwitter_bot.py > bot.log 2>&1
echo "Active screen sessions:"
screen -ls