Feature/forum v2 #24
Workflow file for this run
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 | |
on: | |
pull_request: | |
types: | |
- opened | |
branches: | |
- develop | |
jobs: | |
ci: | |
name: Backend Continuous Integration | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Create and activate virtual environment | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
python3 -m pip install -e . | |
python3 -m pip install -e .[dev] | |
# - name: Run Tests | |
# run: | | |
# source venv/bin/activate | |
# pytest | |
cd: | |
name: Continuous Delivery | |
runs-on: ubuntu-latest | |
needs: ci | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# - name: Check Alembic Migration Version | |
# id: alembicChecker | |
# uses: DevGlitch/[email protected] | |
# with: | |
# db_url: ${{ secrets.DB_URL }} | |
# migrations_path: ./migrations/ | |
# - name: check Alembic migration | |
# id: alembicChecker | |
# uses: appleboy/[email protected] | |
# with: | |
# host: ${{ secrets.SSH_HOST }} | |
# username: ${{ secrets.SSH_USER }} | |
# password: ${{ secrets.SSH_PASSCODE }} | |
# port: ${{ secrets.SSH_PORT }} | |
# script: | | |
# cd /diskb/home/backend | |
# git pull origin develop | |
# . /diskb/home/backend/.venv/bin/activate | |
# alembic heads > heads_output.txt | |
# alembic current > current_output.txt | |
# if cmp -s heads_output.txt current_output.txt; then | |
# echo "No new migrations to apply." | |
# echo "new_migrations=false" >> $GITHUB_ENV | |
# else | |
# echo "New migrations found." | |
# echo "new_migrations=true" >> $GITHUB_ENV | |
# fi | |
- name: executing remote ssh commands using password | |
if: ${{failure() && steps.alembicChecker == 'failure'}} | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
password: ${{ secrets.SSH_PASSCODE }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
cd /diskb/home/backend | |
git pull origin develop | |
. /diskb/home/backend/.venv/bin/activate | |
./start_uspolis_back.sh >> /home/ubuntu/script_log.log 2>&1 | |
- name: Notify Command Success | |
run: echo "Command executed on ${{ secrets.HOST }} successfully!" | |
# - name: Connect to USP Server Machine | |
# run: | | |
# ssh [email protected] -p 2222 | |
# ${{ secrets.SSH_PASSCODE }} | |
# cd /diskb/home/backend | |
# source venv/bin/activate | |
# git pull | |
# alembic upgrade heads | |