-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (102 loc) · 2.94 KB
/
main.yml
File metadata and controls
106 lines (102 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Backend CI
on:
push:
branches:
- prod
jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry lock
poetry install --no-root
- name: Test with pytest
run: |
poetry run pytest -vv
env:
DB_ENGINE: django.db.backends.sqlite3
DB_NAME: db.sqlite3
DB_HOST: localhost
DB_PORT: 5432
DB_USER: user
DB_PASSWORD: password
build-and-push-to-dockerhub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: true
tags: fsdforselfdev/linguista:latest
# deploy:
# name: Pull latest Docker image from Docker Hub
# runs-on: ubuntu-latest
# needs: build-and-push-to-dockerhub
# steps:
# - name: executing remote ssh commands to deploy
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.HOST }}
# username: ${{ secrets.USER }}
# password: ${{ secrets.PASSWORD }}
# key: ${{ secrets.SSH_KEY }}
# script: |
# sudo docker pull fsdforselfdev/linguista:latest
# sudo docker stop
# sudo docker run --rm -d -p 5000:5000 fsdforselfdev/linguista:latest
deploy:
name: Pull latest updates
runs-on: ubuntu-latest
needs: tests
steps:
- name: executing remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
password: ${{ secrets.PASSWORD }}
key: ${{ secrets.SSH_KEY }}
script: |
cd ${{ secrets.HOME_PATH }}/LinguistaAPI
echo ${{ secrets.PASSWORD }} |
sudo -S git stash
sudo -S git pull
sudo -S chmod +x build.sh
sudo -S ./build.sh
sudo -S systemctl daemon-reload
sudo -S systemctl restart gunicorn
sudo -S systemctl reload nginx
send_message:
name: Send success message
runs-on: ubuntu-latest
needs: deploy
steps:
- name: send message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: ${{ github.workflow }} успешно выполнен.