-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
24 lines (21 loc) · 1.26 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
image: python:3.11.4-slim-buster
stages:
- deploy
before_script:
- python3 -V
deploy_job:
stage: deploy
only:
- main
script:
- echo "Starting Deploy Job"
- ssh $USER@$SERVER 'echo "Making project directory" && mkdir -p ~/projects/tgbots/stine'
- ssh $USER@$SERVER 'echo "Pulling latest changes" && cd ~/projects/tgbots/stine && git pull origin main'
- ssh $USER@$SERVER 'echo "Installing requirements" && pip3 install -r ~/projects/tgbots/stine/requirements.txt'
- ssh $USER@$SERVER 'echo "Killing any existing tmux sessions" && tmux kill-session -t tgstinebot || true'
- ssh $USER@$SERVER "echo -e 'Exporting environment variables to .env file' && echo -e 'STINE_API_ID=$STINE_API_ID\nSTINE_API_HASH=$STINE_API_HASH\nSTINE_API_TOKEN=$STINE_API_TOKEN' > ~/projects/tgbots/stine/.env"
- ssh $USER@$SERVER 'echo "Creating new tmux session" && tmux new-session -d -s tgstinebot'
- ssh $USER@$SERVER 'echo "Changing directory" && tmux send-keys -t tgstinebot "cd ~/projects/tgbots/stine" C-m'
- ssh $USER@$SERVER 'echo "Sourcing environment variables" && tmux send-keys -t tgstinebot "source .env" C-m'
- ssh $USER@$SERVER 'echo "Executing Python Script" && tmux send-keys -t tgstinebot "python3 bot.py" C-m'
- echo "Deploy job completed"