From f0540a2bff4f0adc2df1dac6353855b08a94b52c Mon Sep 17 00:00:00 2001 From: Bill Welense Date: Mon, 16 Mar 2026 12:12:45 -0500 Subject: [PATCH 1/2] Add GitHub Action to fetch model garden data Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/fetch-models.yml | 29 ++++++++++++++++++++ scripts/fetch-models.js | 43 ++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/fetch-models.yml create mode 100644 scripts/fetch-models.js diff --git a/.github/workflows/fetch-models.yml b/.github/workflows/fetch-models.yml new file mode 100644 index 0000000..379240b --- /dev/null +++ b/.github/workflows/fetch-models.yml @@ -0,0 +1,29 @@ +name: Fetch Model Garden + +on: + workflow_dispatch: + +jobs: + fetch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Fetch models + run: node scripts/fetch-models.js + env: + MODULAR_CLOUD_API_TOKEN: ${{ secrets.MODULAR_CLOUD_API_TOKEN }} + MODULAR_CLOUD_ORG: ${{ secrets.MODULAR_CLOUD_ORG }} + MODULAR_CLOUD_BASE_URL: ${{ secrets.MODULAR_CLOUD_BASE_URL }} + + - name: Commit and push + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add data/models.json + git diff --cached --quiet || git commit -m "Update models.json" + git push diff --git a/scripts/fetch-models.js b/scripts/fetch-models.js new file mode 100644 index 0000000..13686f9 --- /dev/null +++ b/scripts/fetch-models.js @@ -0,0 +1,43 @@ +import { writeFileSync, mkdirSync } from 'fs'; +import { join, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +const { MODULAR_CLOUD_API_TOKEN, MODULAR_CLOUD_ORG, MODULAR_CLOUD_BASE_URL } = process.env; + +if (!MODULAR_CLOUD_API_TOKEN || !MODULAR_CLOUD_ORG || !MODULAR_CLOUD_BASE_URL) { + console.error('Missing required environment variables'); + process.exit(1); +} + +const headers = { + 'X-Yatai-Api-Token': MODULAR_CLOUD_API_TOKEN, + 'X-Yatai-Organization': MODULAR_CLOUD_ORG, +}; + +async function fetchModelGarden() { + const countRes = await fetch(`${MODULAR_CLOUD_BASE_URL}/api/v1/model_garden`, { headers }); + if (!countRes.ok) throw new Error(`Count request failed: ${countRes.status}`); + const { total } = await countRes.json(); + + const listRes = await fetch(`${MODULAR_CLOUD_BASE_URL}/api/v1/model_garden?count=${total}`, { + headers, + }); + if (!listRes.ok) throw new Error(`List request failed: ${listRes.status}`); + const data = await listRes.json(); + + return data; +} + +fetchModelGarden() + .then((data) => { + const outDir = join(__dirname, '..', 'data'); + mkdirSync(outDir, { recursive: true }); + writeFileSync(join(outDir, 'models.json'), JSON.stringify(data, null, 2)); + console.log(`Wrote ${outDir}/models.json`); + }) + .catch((err) => { + console.error(err); + process.exit(1); + }); From 9e22528590cf80dccb3e7d4bc8978905d1bbd417 Mon Sep 17 00:00:00 2001 From: Bill Welense Date: Mon, 16 Mar 2026 13:05:33 -0500 Subject: [PATCH 2/2] Add nightly schedule to fetch-models workflow - Run model garden fetch daily at midnight UTC - Retain manual workflow_dispatch trigger --- .github/workflows/fetch-models.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/fetch-models.yml b/.github/workflows/fetch-models.yml index 379240b..3d73997 100644 --- a/.github/workflows/fetch-models.yml +++ b/.github/workflows/fetch-models.yml @@ -1,6 +1,8 @@ name: Fetch Model Garden on: + schedule: + - cron: '0 0 * * *' workflow_dispatch: jobs: