first commit
This commit is contained in:
68
.gitea/workflows/deploy.yml
Normal file
68
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
# Gitea Actions CI/CD pipeline: lint → test → deploy
|
||||
# Triggers on push to main branch.
|
||||
#
|
||||
# Required secrets (set in Gitea repo settings):
|
||||
# DEPLOY_HOST — server IP or hostname
|
||||
# DEPLOY_USER — SSH username on the server
|
||||
# DEPLOY_KEY — SSH private key for deployment
|
||||
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- run: pip install ruff
|
||||
- run: ruff check app/
|
||||
|
||||
test:
|
||||
needs: lint
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16
|
||||
env:
|
||||
POSTGRES_DB: test_db
|
||||
POSTGRES_USER: test_user
|
||||
POSTGRES_PASSWORD: test_pass
|
||||
ports:
|
||||
- 5432:5432
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- run: pip install -e ".[dev]"
|
||||
- run: alembic upgrade head
|
||||
env:
|
||||
DATABASE_URL: postgresql+asyncpg://test_user:test_pass@localhost:5432/test_db
|
||||
- run: pytest --tb=short
|
||||
env:
|
||||
DATABASE_URL: postgresql+asyncpg://test_user:test_pass@localhost:5432/test_db
|
||||
|
||||
deploy:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Deploy via SSH
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: ${{ secrets.DEPLOY_HOST }}
|
||||
username: ${{ secrets.DEPLOY_USER }}
|
||||
key: ${{ secrets.DEPLOY_KEY }}
|
||||
script: |
|
||||
cd /opt/stock-data-backend
|
||||
git pull origin main
|
||||
source .venv/bin/activate
|
||||
pip install -e .
|
||||
alembic upgrade head
|
||||
sudo systemctl restart stock-data-backend
|
||||
Reference in New Issue
Block a user