-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (36 loc) · 1.14 KB
/
deploy.yml
File metadata and controls
47 lines (36 loc) · 1.14 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
name: Deploy
on: [push, workflow_dispatch]
jobs:
run_pull:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt pytest
- name: Run pytest
run: |
python -m pytest -v
- name: Deploy on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd ${{ secrets.WORK_DIR }}
branch_name=$(basename ${{ github.ref }})
git checkout ${{ secrets.MAIN_BRANCH }}
git fetch --all
git reset --hard origin/$branch_name
source venv/bin/activate
pip install --upgrade --force-reinstall -r requirements.txt
systemctl --user restart ${{ secrets.SERVICE_NAME }}
exit