From 5d5e2c062a4876e590f8d5a9fe59833d7b1e3684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Mon, 16 Nov 2026 11:40:45 +0000 Subject: [PATCH] ci(skills): read the ClawHub token from the main-only clawhub environment (#7923) --- .github/workflows/sync-skills-to-clawhub.yml | 2 ++ scripts/publish-main-only-workflows.test.mjs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/sync-skills-to-clawhub.yml b/.github/workflows/sync-skills-to-clawhub.yml index 96087fa793..30b0efe951 100644 --- a/.github/workflows/sync-skills-to-clawhub.yml +++ b/.github/workflows/sync-skills-to-clawhub.yml @@ -34,6 +34,8 @@ jobs: name: Publish changed skills # A dispatch runs this file from the chosen branch, so only main may reach the token. if: github.ref == 'refs/heads/main' + # The token is an environment secret; the environment admits only main. + environment: clawhub runs-on: ubuntu-latest timeout-minutes: 10 env: diff --git a/scripts/publish-main-only-workflows.test.mjs b/scripts/publish-main-only-workflows.test.mjs index d289506ff0..d10fa4f7c8 100644 --- a/scripts/publish-main-only-workflows.test.mjs +++ b/scripts/publish-main-only-workflows.test.mjs @@ -103,6 +103,7 @@ test("a publishing job that can be dispatched runs only for main", () => { test("the ClawHub token reaches only the pinned CLI login step", () => { const { source, doc } = workflows.find(({ file }) => file === "sync-skills-to-clawhub.yml"); const sync = doc.jobs.sync; + assert.equal(sync.environment, "clawhub"); assert.equal(source.match(/secrets\.CLAWHUB_TOKEN/g).length, 1); assert.ok(!usesPublishSecret(doc.env)); assert.ok(!usesPublishSecret(sync.env)); @@ -152,3 +153,12 @@ test("dispatch arrays and OR suffixes cannot evade the main guard", () => { ); } }); + +test("a job that reads a stored secret binds an environment", () => { + const unbound = workflows.flatMap(({ file, doc }) => + Object.entries(doc.jobs ?? {}) + .filter(([, job]) => usesPublishSecret(job) && !job.environment) + .map(([name]) => `${file} ${name}`), + ); + assert.deepEqual(unbound, []); +});