Skip to content

Loading from config #17

Loading from config

Loading from config #17

Workflow file for this run

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
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: Initialize database
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 src/db_manager.py
- name: Test python code
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
python -m unittest discover -s tests -p 'test_*.py'
- 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