Compare commits
2 Commits
4d64db45c8
...
8873728a4f
| Author | SHA1 | Date | |
|---|---|---|---|
| 8873728a4f | |||
| 9f73077207 |
35
.gitea/workflows/ci.yml
Normal file
35
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["*"]
|
||||||
|
pull_request:
|
||||||
|
branches: ["*"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
quality-checks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.14"
|
||||||
|
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v4
|
||||||
|
with:
|
||||||
|
version: "0.11.1"
|
||||||
|
enable-cache: true
|
||||||
|
|
||||||
|
- name: Run pre-commit hooks
|
||||||
|
run: uv run pre-commit run --all-files
|
||||||
|
|
||||||
|
- name: Run type checking with ty
|
||||||
|
run: uv run ty
|
||||||
|
|
||||||
|
- name: Run tests with pytest
|
||||||
|
run: uv run pytest
|
||||||
57
.gitea/workflows/deploy.yml
Normal file
57
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
name: Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["CI"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
branches: ["main"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Only deploy if CI workflow succeeded
|
||||||
|
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Stop existing containers
|
||||||
|
run: |
|
||||||
|
# Stop and remove existing containers if they exist
|
||||||
|
docker compose down --remove-orphans || true
|
||||||
|
|
||||||
|
- name: Build and deploy with Docker Compose
|
||||||
|
run: |
|
||||||
|
# Build images
|
||||||
|
docker compose build
|
||||||
|
|
||||||
|
# Deploy the stack in detached mode
|
||||||
|
export GOOGLE_BOOKS_API_KEY="${{ secrets.GOOGLE_BOOKS_API_KEY }}"
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# Wait for health checks to pass
|
||||||
|
echo "Waiting for application to be healthy..."
|
||||||
|
timeout 300 sh -c 'until docker compose ps | grep -q "healthy"; do sleep 5; done'
|
||||||
|
|
||||||
|
- name: Verify deployment
|
||||||
|
run: |
|
||||||
|
# Check if all services are running
|
||||||
|
docker compose ps
|
||||||
|
|
||||||
|
# Test if the application responds
|
||||||
|
sleep 10
|
||||||
|
curl -f http://localhost:5123 || exit 1
|
||||||
|
|
||||||
|
echo "Deployment successful!"
|
||||||
|
|
||||||
|
- name: Cleanup old images
|
||||||
|
run: |
|
||||||
|
# Remove dangling images to save space
|
||||||
|
docker image prune -f
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||||
# uv version.
|
# uv version.
|
||||||
rev: 0.10.10
|
rev: 0.11.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: uv-lock
|
- id: uv-lock
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ services:
|
|||||||
- "5000"
|
- "5000"
|
||||||
environment:
|
environment:
|
||||||
- FLASK_ENV=production
|
- FLASK_ENV=production
|
||||||
|
- GOOGLE_BOOKS_API_KEY=${GOOGLE_BOOKS_API_KEY}
|
||||||
networks:
|
networks:
|
||||||
- hxbooks
|
- hxbooks
|
||||||
# Health check to ensure app is ready
|
# Health check to ensure app is ready
|
||||||
@@ -31,8 +32,7 @@ services:
|
|||||||
image: caddy:2-alpine
|
image: caddy:2-alpine
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "5123:80"
|
||||||
- "443:443"
|
|
||||||
volumes:
|
volumes:
|
||||||
# Caddyfile configuration
|
# Caddyfile configuration
|
||||||
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ def create_app(test_config: dict | None = None) -> Flask:
|
|||||||
app.config.from_mapping(
|
app.config.from_mapping(
|
||||||
SECRET_KEY="dev",
|
SECRET_KEY="dev",
|
||||||
# Put database in project root
|
# Put database in project root
|
||||||
SQLALCHEMY_DATABASE_URI=f"sqlite:///{PROJECT_ROOT / 'hxbooks.sqlite'}",
|
SQLALCHEMY_DATABASE_URI=f"sqlite:///{PROJECT_ROOT / 'instance/hxbooks.sqlite'}",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
|
|||||||
Reference in New Issue
Block a user