125 lines
5.2 KiB
YAML
125 lines
5.2 KiB
YAML
name: Demo images
|
|
|
|
# Builds and pushes the public-demo images on every change to the UI / mock
|
|
# backend, so the separated `archy-demo` Portainer stack auto-tracks the real
|
|
# code (see demo-deploy/ and docs/demo-deployment-design.md).
|
|
#
|
|
# Required repo configuration:
|
|
# vars.DEMO_REGISTRY e.g. source.archipelago-foundation.org/lfg2025
|
|
# vars.DEMO_REGISTRY_HOST registry host for docker login (no org suffix)
|
|
# secrets.DEMO_REGISTRY_USER
|
|
# secrets.DEMO_REGISTRY_TOKEN
|
|
# Optional:
|
|
# secrets.PORTAINER_WEBHOOK redeploy hook called after a successful push
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'neode-ui/**'
|
|
- 'aiui/**'
|
|
- 'scripts/build-aiui.sh'
|
|
- '.dockerignore'
|
|
- 'docker-compose.demo.yml'
|
|
- '.gitea/workflows/demo-images.yml'
|
|
workflow_dispatch:
|
|
inputs:
|
|
operation:
|
|
description: Build and deploy the demo, or clean disposable runner storage
|
|
type: choice
|
|
options: [build, storage]
|
|
default: build
|
|
required: false
|
|
|
|
jobs:
|
|
build:
|
|
name: Build & push demo images
|
|
runs-on: ubuntu-latest
|
|
# Skip cleanly on forks / before registry config is set.
|
|
if: ${{ vars.DEMO_REGISTRY != '' && inputs.operation != 'storage' }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Check runner storage
|
|
run: |
|
|
df -h /
|
|
docker system df
|
|
used=$(df -P / | awk 'NR == 2 {gsub(/%/, "", $5); print $5}')
|
|
if [ "$used" -ge 85 ]; then
|
|
# Only unused cache and untagged images older than a week.
|
|
# Running containers, tagged images and volumes are preserved.
|
|
docker builder prune --force --filter until=168h --keep-storage 10GB
|
|
docker image prune --force --filter until=168h
|
|
df -h /
|
|
docker system df
|
|
fi
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
# Use the public HTTPS registry, including for BuildKit pushes.
|
|
# Plain HTTP redirects can change upload POST requests into GET requests.
|
|
buildkitd-config-inline: |
|
|
[registry."${{ vars.DEMO_REGISTRY_HOST || vars.DEMO_REGISTRY }}"]
|
|
http = false
|
|
|
|
- name: Log in to registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ vars.DEMO_REGISTRY_HOST || vars.DEMO_REGISTRY }}
|
|
username: ${{ secrets.DEMO_REGISTRY_USER }}
|
|
password: ${{ secrets.DEMO_REGISTRY_TOKEN }}
|
|
|
|
- name: Build & push backend
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: neode-ui/Dockerfile.backend
|
|
push: true
|
|
tags: |
|
|
${{ vars.DEMO_REGISTRY }}/archy-demo-backend:demo
|
|
${{ vars.DEMO_REGISTRY }}/archy-demo-backend:${{ github.sha }}
|
|
|
|
- name: Build & push web
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: neode-ui/Dockerfile.web
|
|
push: true
|
|
build-args: |
|
|
VITE_DEMO=1
|
|
SOURCE_REVISION=${{ github.sha }}
|
|
tags: |
|
|
${{ vars.DEMO_REGISTRY }}/archy-demo-web:demo
|
|
${{ vars.DEMO_REGISTRY }}/archy-demo-web:${{ github.sha }}
|
|
|
|
- name: Trigger Portainer redeploy
|
|
# Source pushes prepare images; public deployment is an explicit post-release action.
|
|
if: ${{ success() && github.event_name == 'workflow_dispatch' && secrets.PORTAINER_WEBHOOK != '' }}
|
|
run: curl -fsS -X POST "${{ secrets.PORTAINER_WEBHOOK }}"
|
|
|
|
storage:
|
|
if: ${{ github.event_name == 'workflow_dispatch' && inputs.operation == 'storage' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Reclaim unreferenced registry data using Gitea maintenance
|
|
run: |
|
|
rules=$(docker exec gitea sqlite3 -readonly /data/gitea/gitea.db 'SELECT count(*) FROM package_cleanup_rule WHERE enabled=1;')
|
|
test "$rules" = 0
|
|
docker exec gitea sqlite3 -readonly /data/gitea/gitea.db "SELECT count(*),coalesce(sum(size),0) FROM package_blob b WHERE NOT EXISTS (SELECT 1 FROM package_file f WHERE f.blob_id=b.id) AND b.created_unix < strftime('%s','now','-1 day');"
|
|
df -h /
|
|
token=$(docker exec --user git gitea gitea --config /data/gitea/conf/app.ini admin user generate-access-token --username lfg2025 --token-name "demo-storage-${{ github.run_id }}" --scopes write:admin --raw | tail -n 1)
|
|
test "${#token}" = 40
|
|
trap 'curl -fsS -X DELETE -H "Authorization: token $token" https://source.archipelago-foundation.org/api/v1/token >/dev/null' EXIT
|
|
curl -fsS -X POST -H "Authorization: token $token" https://source.archipelago-foundation.org/api/v1/admin/cron/cleanup_packages
|
|
for attempt in $(seq 1 12); do
|
|
sleep 2
|
|
remaining=$(docker exec gitea sqlite3 -readonly /data/gitea/gitea.db "SELECT count(*) FROM package_blob b WHERE NOT EXISTS (SELECT 1 FROM package_file f WHERE f.blob_id=b.id) AND b.created_unix < strftime('%s','now','-1 day');")
|
|
[ "$remaining" = 0 ] && break
|
|
done
|
|
echo "Expired unreferenced blobs remaining: $remaining"
|
|
docker builder prune --force --all --filter until=24h
|
|
docker exec gitea sh -c 'df -h /data; du -sh /data/gitea/packages'
|
|
docker system df
|