Fix deployment script #72
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Connect to DigitalOcean Droplet | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
script: | | |
set -e | |
# Update the repository and install dependencies | |
cd ~ | |
rm -rf ./pc-components | |
git clone https://github.com/Pansysk75/pc-components.git | |
# API server setup | |
cd ~/pc-components/api-server | |
python3 -m venv venv | |
source venv/bin/activate | |
pip install -r requirements.txt | |
export DATABASE_URI=${{ secrets.DATABASE_URI }} | |
# Start or reload API server using PM2 | |
pm2 reload api-server || pm2 start run.py --name api-server --interpreter ./venv/bin/python3 --update-env | |
# Web app setup | |
cd ~/pc-components/web-app | |
npm install | |
# Start or reload web app using PM2 | |
pm2 reload web-server || pm2 start server.js --name web-app --update-env | |
# Save PM2 process list | |
pm2 save |