Organization Actions Policy
Definition of an Organization Actions Policy, the following properties are supported:
| Key | Value | Description | Notes |
|---|---|---|---|
| name | string | The name of this actions policy | Must be unique within the organization |
| enforcement | string | The enforcement status of this actions policy | active, disabled or evaluate, evaluate is only available with GitHub Enterprise |
| include_repo_names | list[RepoNameMatcher] | List of names or patterns to include matching repositories | ~ALL targets all repositories, an empty list targets none |
| exclude_repo_names | list[RepoNameMatcher] | List of names or patterns to exclude matching repositories | |
| protect_repo_names | boolean | If enabled, the targeted repositories can not be renamed | |
| include_workflows | list[string] | List of workflow files or patterns targeted by the policy | ~ALL targets all workflows, e.g. .github/workflows/release.yml or .github/workflows/* |
| exclude_workflows | list[string] | List of workflow files or patterns excluded from the policy | ~ALL is not allowed |
| allowed_actors | list[AllowedActor] or null | Rule: the actors allowed to run the targeted workflows | null does not require the rule |
| allowed_events | list[string] or null | Rule: the events allowed to trigger the targeted workflows | e.g. push, pull_request or workflow_dispatch, null does not require the rule |
An actions policy, called workflow execution protection by GitHub, blocks the runs of the targeted workflows that it does not allow, see Controlling workflow execution. The policies of the enterprise are not managed by otterdog, the ones of a repository are defined with the Repository Actions Policy.
The rules of a policy that otterdog does not support, e.g. Require lockfile whose rule GitHub does not publish in its API yet, are kept when otterdog updates the policy. A rule missing from the configuration, e.g. with a default configuration predating it, is not managed either and keeps its current value, as does a key of the workflow or repository targeting missing from the configuration while another one is configured.
GitHub does not allow two policies with the same name. When otterdog adds a policy whose name is already used by a policy that the configuration does not know, e.g. created in the web UI, it updates that policy instead.
A policy that targets repositories by custom property or by id, which otterdog does not support, keeps this
targeting when otterdog updates the policy, its include_repo_names, exclude_repo_names and
protect_repo_names are not compared.
Jsonnet Function¶
The default values of an actions policy:
# Function to create a new repository actions policy with default settings.
local newRepoActionsPolicy(name) = {
name: name,
enforcement: "active",
# the workflows targeted by the policy, '~ALL' targets all workflows
include_workflows: ["~ALL"],
exclude_workflows: [],
# the rules of the policy, null does not require a rule
# the actors allowed to run the targeted workflows
allowed_actors: null,
# the events allowed to trigger the targeted workflows
allowed_events: null,
};
# Function to create a new organization actions policy with default settings.
local newOrgActionsPolicy(name) = newRepoActionsPolicy(name) {
include_repo_names: [],
exclude_repo_names: [],
protect_repo_names: false,
};
Validation rules¶
- setting
enforcementtoevaluatefor an organization on a nonenterpriseplan triggers an error - setting both
include_workflowsandexclude_workflowsto empty lists triggers an error, use~ALLto target all workflows - combining
~ALLwith other patterns ininclude_workflows, or using~ALLinexclude_workflowstriggers an error - setting an invalid allowed actor, e.g. an unknown role, triggers an error
- setting an event in
allowed_eventsthat otterdog does not know triggers a warning - setting
allowed_actorsorallowed_eventsto an empty list triggers a warning, as it blocks all the targeted workflows - a policy that does not require any rule triggers a warning, as it has no effect
- an empty
include_repo_namestriggers a warning, as the policy does not apply to any repository - a pattern of
include_repo_namesorexclude_repo_namesthat does not match any repository triggers a warning - setting
protect_repo_nameswhileinclude_repo_namesandexclude_repo_namesare empty triggers a warning
Example usage¶
The following policy only allows workflows of the repositories of the organization to be triggered by pushes,
pull requests and manual runs, e.g. it blocks pull_request_target: