fixes #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Server | |
on: | |
push: | |
branches: | |
- main # Замените на нужную ветку | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' # Убедитесь, что версия Python соответствует требованиям пакетов | |
- name: Install dependencies | |
run: | | |
python -m venv venv | |
. venv/bin/activate | |
# pip install -r requirements.txt | |
- name: Start SSH agent | |
run: | | |
eval "$(ssh-agent -s)" | |
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Copy files to server | |
env: | |
SERVER_HOST: ${{ secrets.SERVER_HOST }} | |
SERVER_USER: ${{ secrets.SERVER_USER }} | |
run: | | |
ssh -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_HOST "mkdir -p /root/repos/askgbt" | |
rsync -avz -e "ssh -o StrictHostKeyChecking=no" . $SERVER_USER@$SERVER_HOST:/root/repos/askgbt | |
- name: Restart application on server | |
env: | |
SERVER_HOST: ${{ secrets.SERVER_HOST }} | |
SERVER_USER: ${{ secrets.SERVER_USER }} | |
run: | | |
ssh -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_HOST << 'EOF' | |
cd /root/repos/askgbt | |
python3 -m venv venv | |
source venv/bin/activate | |
# pip install -r requirements.txt | |
# Останавливаем текущий процесс вашего приложения, если он запущен | |
pkill -f main.py || true | |
# Запускаем ваше приложение | |
nohup python3 main.py & | |
EOF |