Changed db directory 2 #13
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: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m venv serenadoit . | |
source serenadoit/bin/activate | |
pip install -r requirements.txt | |
- name: Run database initialization | |
run: | | |
cd src | |
python db_manager.py | |
- name: Run tests | |
run: | | |
cd tests | |
python -m unittest discover -s . -p 'test_*.py' | |
deploy: | |
name: Deploy to Server | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout Repository | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
port: ${{ secrets.SERVER_PORT }} | |
script: | | |
cd serenadoit | |
git stash | |
git pull origin master | |
git stash pop | |
rm -rf ~/node/static/styles/ ~/node/static/scripts/ ~/node/static/images/ | |
cp -r ./static ~/node/ | |
- name: Install dependencies and restart server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
port: ${{ secrets.SERVER_PORT }} | |
script: | | |
cd serenadoit | |
python -m venv serenadoit . | |
source serenadoit/bin/activate | |
pip install -r requirements.txt | |
kill $(ps aux | grep "^${{ secrets.SERVER_USERNAME }}" | grep '[g]unicorn' | awk '{print $2}') || true | |
- name: SSH to server and deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
port: ${{ secrets.SERVER_PORT }} | |
script: | | |
cd serenadoit | |
source serenadoit/bin/activate | |
gunicorn -w 4 -b 0.0.0.0:10410 run_prod:app --error-logfile logs/error.log --access-logfile logs/access.log -D | |
- name: Check deployment | |
run: | | |
ps aux | grep "^$USER" | grep '[g]unicorn' || true | |