-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (30 loc) · 1.13 KB
/
Copy pathdeploy.yml
File metadata and controls
35 lines (30 loc) · 1.13 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
name: Deploy
on:
workflow_run:
workflows:
- CI
types:
- completed
jobs:
deploy:
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'main'
runs-on: ubuntu-latest
steps:
- name: Setup SSH key
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Add deploy host to known_hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H "${{ secrets.DEPLOY_HOST }}" >> ~/.ssh/known_hosts
- name: Deploy on server
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
run: |
TARGET_PATH="${DEPLOY_PATH:-/opt/tpbot}"
ssh "${DEPLOY_USER}@${DEPLOY_HOST}" "sudo bash -lc 'set -e; cd ${TARGET_PATH}; git pull --ff-only; docker compose up -d --build api control_bot intake_bot; docker exec tpbot-api-1 alembic upgrade head; curl -fsS http://127.0.0.1:8000/health >/dev/null; curl -fsS http://127.0.0.1:8000/tasks/active >/dev/null'"