Skip to content

Commit

Permalink
add github workflow for deploying api
Browse files Browse the repository at this point in the history
  • Loading branch information
ericcccsliu committed Mar 29, 2024
1 parent 472dd43 commit 9f54084
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/deploy_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 '
cd hackgpt
git pull origin main -- Dockerfile api/ requirements.txt
echo "$ENV_FILE_CONTENT" > .env
docker build -t hackgpt .
docker stop $(docker ps -q --filter ancestor=hackgpt)
docker run -d -p 8000:8000 hackgpt
'

0 comments on commit 9f54084

Please sign in to comment.