|
| 1 | +# Refresh the committed site catalog from live AgentFront conformance. |
| 2 | +# |
| 3 | +# tools.culture.dev (M3) is hosted on Cloudflare Pages via git-integration, which |
| 4 | +# builds site-astro/ from the *committed* catalog.json. So as sibling tools change |
| 5 | +# versions or cross the conformance line, the live index goes stale until the |
| 6 | +# catalog is regenerated. This job does that regeneration on a schedule (and on |
| 7 | +# demand) and opens a PR — it never commits to main directly, so a human reviews |
| 8 | +# the version/conformance diff before a merge triggers the CF rebuild. |
| 9 | +# |
| 10 | +# Status: needs a first `workflow_dispatch` run to validate in CI. |
| 11 | +# Secrets (both optional): |
| 12 | +# SIBLING_REPOS_TOKEN read-access PAT to clone *private* siblings; public |
| 13 | +# ones clone with the default GITHUB_TOKEN. Without it, |
| 14 | +# private siblings are reported as excluded. |
| 15 | +# CATALOG_REFRESH_PR_TOKEN write PAT / App token for opening the refresh PR. |
| 16 | +# Only needed if you want that PR to trigger CI — PRs |
| 17 | +# opened by the default GITHUB_TOKEN do not. Falls back |
| 18 | +# to GITHUB_TOKEN (which can still open the PR). |
| 19 | +name: catalog-refresh |
| 20 | + |
| 21 | +on: |
| 22 | + schedule: |
| 23 | + - cron: "0 6 * * 1" # Mondays 06:00 UTC |
| 24 | + workflow_dispatch: {} |
| 25 | + |
| 26 | +permissions: |
| 27 | + contents: write |
| 28 | + pull-requests: write |
| 29 | + |
| 30 | +concurrency: |
| 31 | + group: catalog-refresh |
| 32 | + cancel-in-progress: false |
| 33 | + |
| 34 | +jobs: |
| 35 | + refresh: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - name: Checkout culture-tools |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Set up uv + Python |
| 42 | + uses: astral-sh/setup-uv@v5 |
| 43 | + with: |
| 44 | + python-version: "3.12" |
| 45 | + |
| 46 | + - name: Install culture-tools (+ dev deps) |
| 47 | + run: uv sync |
| 48 | + |
| 49 | + - name: Install the AgentFront auditor |
| 50 | + run: | |
| 51 | + uv tool install agentfront |
| 52 | + echo "$HOME/.local/bin" >> "$GITHUB_PATH" |
| 53 | +
|
| 54 | + - name: Clone candidate sibling repos (from the manifest) |
| 55 | + env: |
| 56 | + GH_TOKEN: ${{ secrets.SIBLING_REPOS_TOKEN || secrets.GITHUB_TOKEN }} |
| 57 | + run: | |
| 58 | + set -euo pipefail |
| 59 | + mkdir -p _siblings |
| 60 | + # Keep the token out of clone URLs and the cloned repos' git config: feed |
| 61 | + # it through GIT_ASKPASS instead, so the URL carries only the |
| 62 | + # x-access-token *username* (not a secret) and nothing is persisted. |
| 63 | + askpass="$RUNNER_TEMP/askpass.sh" |
| 64 | + printf '#!/bin/sh\necho "$GH_TOKEN"\n' > "$askpass" |
| 65 | + chmod +x "$askpass" |
| 66 | + export GIT_ASKPASS="$askpass" GIT_TERMINAL_PROMPT=0 |
| 67 | + # The manifest is the single source of truth for what to fetch — emit |
| 68 | + # "<owner/repo>\t<dir>" rows so this never drifts from the Python list. |
| 69 | + uv run python - > _siblings/manifest.tsv <<'PY' |
| 70 | + from culture_tools.index import candidates |
| 71 | + for tool in candidates(): |
| 72 | + print(f"{tool.repo}\t{tool.repo_dir}") |
| 73 | + PY |
| 74 | + while IFS=$'\t' read -r repo dir; do |
| 75 | + [ -z "${repo:-}" ] && continue |
| 76 | + echo "::group::clone $repo -> _siblings/$dir" |
| 77 | + git clone --depth 1 \ |
| 78 | + "https://x-access-token@github.com/${repo}.git" \ |
| 79 | + "_siblings/$dir" \ |
| 80 | + || echo "skip: could not clone $repo (private/missing) — it will be excluded" |
| 81 | + echo "::endgroup::" |
| 82 | + done < _siblings/manifest.tsv |
| 83 | + rm -f _siblings/manifest.tsv |
| 84 | +
|
| 85 | + - name: Enrich (best-effort) — install conformant tools for `learn --json` |
| 86 | + continue-on-error: true |
| 87 | + run: | |
| 88 | + # Optional layer: populates each listed tool's purpose + command map. |
| 89 | + # If a tool can't be installed the catalog still builds; that entry just |
| 90 | + # carries no command surface. Never fails the job. |
| 91 | + for pkg in agentfront colleague culture-tools; do |
| 92 | + uv tool install "$pkg" || echo "skip install $pkg" |
| 93 | + done |
| 94 | +
|
| 95 | + - name: Regenerate the catalog |
| 96 | + run: | |
| 97 | + set -euo pipefail |
| 98 | + uv run culture-tools index build --out _stage --repos-dir _siblings |
| 99 | + cp _stage/catalog.json site-astro/src/data/catalog.json |
| 100 | + rm -rf site-astro/public/simple |
| 101 | + cp -r _stage/simple site-astro/public/simple |
| 102 | + rm -rf _siblings _stage |
| 103 | +
|
| 104 | + - name: Open a PR if the catalog changed |
| 105 | + uses: peter-evans/create-pull-request@v7 |
| 106 | + with: |
| 107 | + # PR creation needs *write*. SIBLING_REPOS_TOKEN is documented read-only |
| 108 | + # (cloning private siblings), so it must NOT be reused here. The default |
| 109 | + # GITHUB_TOKEN works via the permissions: block above; note that a PR it |
| 110 | + # opens does not itself trigger CI — set CATALOG_REFRESH_PR_TOKEN (a PAT |
| 111 | + # or App token) if you want the refresh PR to run checks automatically. |
| 112 | + token: ${{ secrets.CATALOG_REFRESH_PR_TOKEN || secrets.GITHUB_TOKEN }} |
| 113 | + base: main |
| 114 | + branch: bot/catalog-refresh |
| 115 | + delete-branch: true |
| 116 | + commit-message: "chore(index): refresh catalog from live conformance" |
| 117 | + title: "chore(index): refresh tools.culture.dev catalog" |
| 118 | + body: | |
| 119 | + Automated catalog refresh from live AgentFront conformance |
| 120 | + (`culture-tools index build --repos-dir <cloned siblings>`). |
| 121 | +
|
| 122 | + **Review the version / conformance diff before merging** — merging to |
| 123 | + `main` triggers a Cloudflare Pages rebuild of tools.culture.dev. If a |
| 124 | + tool's command surface looks stripped, its package likely failed to |
| 125 | + install in the enrichment step (non-fatal) — re-run or hold. |
| 126 | +
|
| 127 | + Generated by `.github/workflows/catalog-refresh.yml`. |
0 commit comments