-
Notifications
You must be signed in to change notification settings - Fork 1
44 lines (40 loc) · 1.3 KB
/
deploy_api.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Deploy to DigitalOcean
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Deploy to DigitalOcean
env:
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PASSWORD: ${{ secrets.PASSWORD }}
ENV_FILE_CONTENT: ${{ secrets.ENV_FILE_CONTENT }}
run: |
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no $USERNAME@$HOST '
mkdir -p hackgpt
cd hackgpt
if [ ! -d .git ]; then
git init
git remote add origin https://github.com/${{ github.repository }}.git
git config core.sparseCheckout true
echo "Dockerfile" >> .git/info/sparse-checkout
echo "api/" >> .git/info/sparse-checkout
echo "requirements.txt" >> .git/info/sparse-checkout
git pull --depth=1 origin main
else
git pull origin main
fi
echo "ENV_FILE_CONTENT:"
echo "$ENV_FILE_CONTENT"
echo "$ENV_FILE_CONTENT" > .env
docker build -t hackgpt .
docker stop hackgpt-container || true
docker rm hackgpt-container || true
docker run -d --name hackgpt-container -p 8000:8000 hackgpt
'