Restrict a self-hosted runner to one workflow in a personal public repository? #213333
Replies: 6 comments 1 reply
|
Not on a personal account: labels do not limit which workflows use a runner. An organization can, also on Free. Create a runner group and set Workflow access to Selected workflows, for example |
|
One distinction for the signing design: a runner group controls which jobs can reach the runner. An environment gates a job and its environment secrets. An environment approval won’t protect a signing key already present on a host that other jobs can reach. For a public personal repo, I would keep the signing key off any runner that accepts its general CI jobs. If you move signing into an organization runner group, set both the repository allowlist and Workflow access → Selected workflows, then pin the reusable signing workflow by full SHA. GitHub says only jobs defined directly in the selected workflow get access. Also verify what that job checks out and accepts as input. Pinning the YAML still leaves a gap if it runs scripts or actions from a caller-controlled ref. |
|
The short answer is no on a personal account, yes with an organisation-level runner group — and the distinction matters because labels are not a security boundary. Why labels are not enoughA runner label is just a string that jobs request. Any workflow in the repository can declare The supported controlsOn an organisation, create a self-hosted runner group and set two things:
That second setting is the one that enforces "one reviewed workflow at a fixed commit". A workflow on another branch, or a different file, will not be assigned that runner. Pin the ref to a full SHA, not a branch name — a branch can be moved by anyone with write access. Then layer an environment on top for the credential:
Check availability of runner groups and "selected workflows" in your organisation's Actions settings — the exact plan entitlements have changed over time, so verify on your org rather than relying on an old blog post. A personal account has no runner groups, so there is no supported way to scope a runner to one workflow there. The part people usually missA runner group controls job placement. It does not protect a key that is already on disk on the host. If any job can reach that machine, the key is reachable. Two safer patterns:
For the untrusted-PR case specifically: Lock down the workflow itselfInside the pinned signing workflow: permissions:
contents: read
id-token: write # only if using OIDCPin every third-party action to a full commit SHA. A floating How to verify it worksCreate a second workflow that requests the same labels with no environment, and run it. Confirm it sits queued indefinitely because no runner in the allowed group will accept it. Also try the pinned workflow from another branch and confirm it isn't assigned. If either test picks up the runner, the group's workflow access isn't configured the way you think. One caveat: runner group "selected workflows" matches the workflow path and ref as GitHub sees it. Renaming the file or moving it invalidates the match, so keep the signing workflow in a stable location and treat its path as part of the security configuration. More CI and security notes on my GitHub if helpful: https://github.com/P-r-e-m-i-u-m |
|
Good point about testing runner access from different workflows and branches. Keeping the workflow path stable is also important for maintaining security. |
|
Thanks, this helps. Does Workflow access → Selected workflows, with a reusable workflow pinned to a full commit SHA, work on a standalone GitHub Free organization that isn't part of an enterprise? The changelog confirms self-hosted runner groups on Free, but the workflow-access instructions I can find are in the Enterprise Cloud docs. If you've seen this setting on a Free organization or know where GitHub documents it, could you share that source? |
|
Good catch — I should have flagged this earlier: the workflow-access instructions I cited were from the Enterprise Cloud docs, and that's the only place GitHub documents them. In the docs source, the "Assign a policy for workflow access" step and the whole "Changing which workflows can access a runner group" section are wrapped in an Enterprise-only version condition, while the Free/Pro/Team page covers only repository access (manage-access.md). The Free-plan changelog confirms runner groups themselves, but says nothing about workflow restrictions. The REST API does expose |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Question
💬 Feature/Topic Area
Other
Discussion Details
Hello.
I am evaluating a design; the signing runner has not been set up. For a public repository owned by a personal account, is there a GitHub-supported way to ensure that only one reviewed workflow at a fixed version or commit can use a signing-capable self-hosted runner or protected job credential, while other workflows in that repository and untrusted fork pull request workflows cannot use it?
If so, which exact settings enforce this? If it requires an organization or enterprise runner group, which plan is required and what are its scope limits? Please explain the limits of runner labels, environment approvals, and workflow restrictions for this purpose.
All reactions