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, []); +});