albion/.forgejo/workflows/deploy.yml
Заид Омар Медхат 337dac78ba
All checks were successful
Deploy / deploy (push) Successful in 3m58s
Client/server split, Postgres, auth, Windows agent, Docker deploy
- Extract world-parse + packet capture into @albion/shared (reused by
  server and a new standalone agent workspace).
- Migrate the data layer from SQLite/better-sqlite3 to shared Postgres
  (async pg with a ?->$n helper; economy engine preloads the item/recipe
  graph so its sync recursion still works).
- API-key auth (ALBION_API_KEY) on all /api routes except health; web UI
  sends it via a fetch wrapper + key-entry gate; server serves the built
  UI with a path-traversal-safe static handler (drops @fastify/static).
- Windows companion agent: pushes world map + captured market orders to
  /api/ingest/*; runs on the gaming PC where the game traffic lives.
- Docker + docker-compose (external proxy + backend networks for Nginx
  Proxy Manager and shared Postgres) and a Forgejo deploy workflow.
- Validated end-to-end against Postgres 16 and a full compose run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-23 04:10:08 +05:00

68 lines
2.8 KiB
YAML

name: Deploy
# Deploy on every push to master (and allow manual runs from the Actions tab).
on:
push:
branches: [master]
workflow_dispatch:
# A STABLE compose project name so the named volume (albion_data, the downloaded
# game-data JSON cache) is the same on every run. App state (prices, profiles,
# world map) lives in the shared Postgres, not the volume. Compose prefixes
# volumes with the project name, so a changing name would orphan the cache.
env:
COMPOSE_PROJECT_NAME: albion
jobs:
deploy:
# `docker` label => node:22-bookworm with the host Docker socket available.
runs-on: docker
steps:
- name: Checkout
uses: actions/checkout@v4
# The job image has the Docker socket available but may not ship the docker
# CLI / compose plugin. Install them only if missing (no-op otherwise) so
# `docker compose ...` can talk to the host daemon.
- name: Ensure Docker CLI + Compose plugin
run: |
if ! command -v docker >/dev/null 2>&1; then
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-27.3.1.tgz \
| tar -xz -C /usr/local/bin --strip-components=1 docker/docker
fi
if ! docker compose version >/dev/null 2>&1; then
mkdir -p /usr/local/lib/docker/cli-plugins
curl -fsSL https://github.com/docker/compose/releases/download/v2.29.7/docker-compose-linux-x86_64 \
-o /usr/local/lib/docker/cli-plugins/docker-compose
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
fi
docker version
docker compose version
# `proxy` is the shared external network Nginx Proxy Manager sits on.
# Create it if it doesn't exist yet so `docker compose up` won't fail.
- name: Ensure 'proxy' network exists
run: docker network inspect proxy >/dev/null 2>&1 || docker network create proxy
# The compose file requires DATABASE_URL and ALBION_API_KEY. Provide them
# from Forgejo Actions secrets so they never live in the repo. Written to
# .env, which docker compose reads automatically.
- name: Write .env
run: |
{
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}"
echo "ALBION_API_KEY=${{ secrets.ALBION_API_KEY }}"
} > .env
# Build the image locally on the host (no external registry needed).
- name: Build image
run: docker compose build
# Reconcile the stack: compose only recreates services whose config or
# image actually changed, and cleans up any services removed from the file.
- name: Deploy stack
run: docker compose up -d --remove-orphans
# Free disk on the shared runner by dropping old, untagged images.
- name: Prune old images
run: docker image prune -f