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