Sub topic 11
Controlling which actions a repository or organization may use
This chapter assumes you can already write a workflow that uses uses: to reference an action, and that you know the owner/repo@ref syntax and the pinning options from earlier chapters. It also assumes you have admin access to a repository or organization, because the settings below are not visible to other roles.
Why restrict actions
Every uses: line runs code from someone else inside your job. An allow policy decides which of those sources a repository may run at all. Vetting an action is a per-action judgment. A policy is a guardrail that applies even when someone skips that judgment.
The policy levels
GitHub evaluates policies from the top down. A lower level can narrow what the level above allows, but it cannot widen it.
If an organization sets a policy, repository admins can only choose options inside it. The repository settings page shows the organization's choice and disables options that would be broader.
The available settings
Open Settings, then Actions, then General. Under Actions permissions you choose one of these options.
| Option | What it allows |
|---|---|
| Disable Actions | No workflows run. |
| Allow all actions and reusable workflows | Any action from anywhere. |
| Allow *owner* actions and reusable workflows | Only actions and reusable workflows defined in repositories owned by that user or organization. |
| Allow *owner*, and select actions and reusable workflows | The owner's own actions, plus the exceptions you tick or list. |
At the organization level the same page lets you choose which repositories may use Actions at all.
Allowing select actions
When you choose the select option, three exceptions become available:
- Actions created by GitHub, which are the ones in the
actionsandgithuborganizations. - Marketplace actions by verified creators.
- A list of specific actions and reusable workflows that you type in.
The list takes one entry per line, or comma-separated. Wildcards let you allow a whole owner or a version range.
actions/cache@*
docker/*
my-org/deploy-action@v2
my-org/shared-workflows/.github/workflows/build.yml@*An entry that names a tag or branch matches only that ref. An entry ending in @* matches any ref. You can also list a full-length commit SHA to approve exactly one reviewed commit.
Requiring SHA pinning
The same settings page has an option to require actions to be pinned to a full-length commit SHA. With it on, a workflow that references actions/checkout@v4 fails, and actions/checkout@<full-length-commit-sha> passes. This turns the pinning advice from the versioning chapter into something GitHub enforces. GitHub has been extending the options on this page, so check the current documentation for the exact wording and any support for blocking specific actions.
What the policy covers
The policy applies to everything a run resolves, not just the lines you wrote:
- Actions in your workflow's
uses:steps. - Reusable workflows called with
uses:at the job level. - Actions that a composite action calls internally.
Because of the last point, a composite action you allowed can still fail the run if it calls an action that your policy does not permit. When that happens, add the nested action to the list or pick a different action.
Local actions, referenced with a path such as ./.github/actions/setup, live in your own repository. They are covered by the "this repository" or "owner" options.
What a blocked action looks like
The run does not start the disallowed step. It fails with a message that names the action and says it is not allowed in the repository. The message usually mentions the policy that blocked it. The fix is a policy decision, not a workflow edit:
- Decide whether the action should be allowed at all. Apply the vetting checks from the earlier chapter.
- If yes, add it to the allowed list at the highest level that makes sense, usually the organization.
- Re-run the workflow. You do not need a new commit.
If the repository page shows the options as greyed out, an organization or enterprise policy is the cause. A repository admin cannot override it. Ask an organization owner.
A practical starting policy
A reasonable default for an organization is:
- Choose the select option.
- Allow actions created by GitHub.
- Allow Marketplace actions by verified creators if your teams rely on common tools.
- List any other approved actions by name, pinned to a reviewed ref.
- Turn on the SHA pinning requirement once Dependabot is configured to keep those pins current.
Doing the Dependabot step first avoids a wave of stale pins.
Exercise
Your organization allows only GitHub-created actions and verified creators. A teammate adds a composite action from a verified creator, and the run fails with a message that a different action is not allowed. What is the most likely cause, and where do you fix it?
Show answer
The composite action calls another action internally, and that nested action is not covered by the policy. Policies apply to every action a run resolves, not only the ones written in your workflow. Fix it in Settings, Actions, General at the organization level by adding the nested action to the allowed list, or by choosing a different action. No workflow change is needed.
Exercise
A repository admin cannot select "Allow all actions and reusable workflows". Why, and who can change it?
Show answer
An organization or enterprise policy is more restrictive, and repositories can only narrow the policy above them. An organization owner, or an enterprise owner if the policy is set there, must change it.