71 lines
1.8 KiB
YAML
71 lines
1.8 KiB
YAML
name: ERP CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
paths:
|
|
- "backend/**"
|
|
- "frontend/**"
|
|
- "docker-compose*.yml"
|
|
- ".gitea/workflows/ci.yml"
|
|
pull_request:
|
|
branches: [main, master]
|
|
paths:
|
|
- "backend/**"
|
|
- "frontend/**"
|
|
- "docker-compose*.yml"
|
|
- ".gitea/workflows/ci.yml"
|
|
|
|
concurrency:
|
|
group: erp-${{ github.ref_name }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
db:
|
|
image: postgres:16-alpine
|
|
env:
|
|
POSTGRES_DB: erp_db
|
|
POSTGRES_PASSWORD: password
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install deps
|
|
run: |
|
|
pip install -r backend/requirements.txt
|
|
pip install pytest pytest-django
|
|
|
|
- name: Run tests
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/erp_db
|
|
run: |
|
|
pytest backend/modules/invoicing/tests/test_services.py
|
|
pytest backend/modules/task_management/tests/test_services.py
|
|
|
|
deploy:
|
|
name: Deploy (server git pull + compose)
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master')
|
|
steps:
|
|
- name: SSH deploy
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
username: ${{ secrets.DEPLOY_USER }}
|
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
port: ${{ secrets.DEPLOY_PORT }}
|
|
script_stop: true
|
|
script: |
|
|
set -e
|
|
export DEPLOY_PATH="${{ secrets.DEPLOY_PATH }}"
|
|
export DEPLOY_BRANCH="${{ github.ref_name }}"
|
|
/usr/local/bin/erp-deploy.sh |