Files
librefang-registry/.github/workflows/refresh-cache.yml
T
Evan Hu ff6f3f2b25 ci: build registry-index.json in-repo for dashboard real-time updates
Pair with the existing plugins-index.json path (which feeds the
daemon's signed install lane). registry-index.json mirrors the
dict-shaped payload the registry-worker's cron currently builds via
40+ GitHub Contents API calls — but built locally from the checked-out
tree by scripts/build-registry-index.mjs, so the worker only fetches
ONE file per category type (2 total: plugins + registry) on refresh.

Workflow now picks up content changes across all 8 category dirs
(was: plugins/ only) so dashboard updates land within seconds of a
push instead of waiting for the 02:00 UTC cron tick.

The dashboard's /api/registry endpoint reads kv_store('registry_data');
the worker's forced-refresh now writes that key with these bytes and
purges the Cache-API entry, so the next dashboard hit sees fresh
data instead of the 1h-cached previous payload.

Generated counts on first build: 11p 17h 32a 60s 44c 57pr 22w 33mcp.
2026-05-05 00:43:30 +09:00

78 lines
2.5 KiB
YAML

name: Refresh registry-worker cache
# On every push that changes any registry content, regenerate the two
# in-repo indexes the registry-worker ingests:
# plugins-index.json — daemon-shaped flat plugins array (signed)
# registry-index.json — dict-shaped dashboard payload (unsigned)
# then poke the worker's forced-refresh endpoint so it pulls both
# (2 subrequests total, regardless of registry size — important under
# Workers Free's 50-subrequest budget) and re-signs / stores them.
#
# Without this, dashboard + daemon would have to wait for the next
# 02:00 UTC cron tick to see content changes (up to ~24h delay).
on:
push:
branches: [main]
paths:
- 'plugins/**'
- 'agents/**'
- 'skills/**'
- 'hands/**'
- 'channels/**'
- 'providers/**'
- 'workflows/**'
- 'mcp/**'
- 'scripts/build-plugins-index.mjs'
- 'scripts/build-registry-index.mjs'
workflow_dispatch:
permissions:
contents: write # commit regenerated index files back
jobs:
refresh:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Rebuild indexes
run: |
node scripts/build-plugins-index.mjs
node scripts/build-registry-index.mjs
- name: Commit regenerated indexes if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add plugins-index.json registry-index.json
if git diff --cached --quiet; then
echo "indexes already up-to-date"
else
git commit -m "chore: regenerate registry indexes"
git push
fi
- name: Trigger worker refresh
env:
REGISTRY_REFRESH_TOKEN: ${{ secrets.REGISTRY_REFRESH_TOKEN }}
run: |
if [ -z "$REGISTRY_REFRESH_TOKEN" ]; then
echo "::error::REGISTRY_REFRESH_TOKEN secret is not set on this repo"
exit 1
fi
response=$(curl -fsS -X POST \
-H "Authorization: Bearer $REGISTRY_REFRESH_TOKEN" \
-w "\nHTTP_CODE:%{http_code}" \
https://stats.librefang.ai/api/registry/refresh)
echo "$response"
code=$(echo "$response" | grep -oE 'HTTP_CODE:[0-9]+' | cut -d: -f2)
if [ "$code" != "200" ]; then
echo "::error::worker returned $code"
exit 1
fi