About GitHub Actions permissions for your organization
默认情况下,GitHub Actions 将在所有仓库和组织上启用。 You can choose to disable GitHub Actions or limit it to actions and reusable workflows in your organization. For more information about GitHub Actions, see "About GitHub Actions."
You can enable GitHub Actions for all repositories in your organization. When you enable GitHub Actions, workflows are able to run actions and reusable workflows located within your repository and any other public repository. You can disable GitHub Actions for all repositories in your organization. 禁用 GitHub Actions 时,仓库中不会运行任何工作流程。
Alternatively, you can enable GitHub Actions for all repositories in your organization but limit the actions and reusable workflows a workflow can run.
Managing GitHub Actions permissions for your organization
You can choose to disable GitHub Actions for all repositories in your organization, or only allow specific repositories. You can also limit the use of public actions and reusable workflows, so that people can only use local actions and reusable workflows that exist in your organization.
Note: You might not be able to manage these settings if your organization is managed by an enterprise that has overriding policy. For more information, see "Enforcing policies for GitHub Actions in your enterprise."
-
在 GitHub.com 的右上角,单击您的头像,然后单击 Your organizations(您的组织)。
-
在组织旁边,单击 Settings(设置)。
-
In the left sidebar, click Actions, then click General.
-
Under "Policies", select an option.
If you choose Allow OWNER, and select non-OWNER, actions and reusable workflows, actions and reusable workflows within your organization are allowed, and there are additional options for allowing other specific actions and reusable workflows. For more information, see "Allowing select actions and reusable workflows to run."
When you allow actions and reusable workflows from only in your organization, the policy blocks all access to actions authored by GitHub. For example, the
actions/checkout
action would not be accessible. -
Click Save.
允许所选操作 和可重启工作流程 运行
选择 Allow OWNER, and select non-OWNER, actions and reusable workflows 时,允许本地操作 和可重用工作流程 ,并且还有其他选项可用于允许其他特定操作 和可重用工作流程:
-
允许 GitHub 创建的操作: 您可以允许 GitHub 创建的所有操作用于工作流程。 GitHub 创建的操作位于
actions
和github
组织中。 更多信息请参阅actions
和github
组织。 -
允许已验证的创建者执行市场操作: 您可以允许工作流程使用由经过验证的创建者创建的所有 GitHub Marketplace 操作。 如果 GitHub 验证该操作的创建者为合作伙伴组织, 徽章将显示在 GitHub Marketplace 中的操作旁边。
-
允许指定的操作 和可重用工作流程: 可以将工作流程限制为使用特定组织和存储库中的操作 和可重用工作流程。
要限制对特定标记的访问或者操作 或可重用工作流程 的提交 SHA,请使用工作流中使用的相同语法来选择操作 或可重用工作流程。
- 对于操作,语法为
<OWNER>/<REPO>@<TAG OR SHA>
。 例如,使用actions/javascript-action@v1.0.1
选择标记,或使用actions/javascript-action@172239021f7ba04fe7327647b213799853a9eb89
选择 SHA。 更多信息请参阅“查找和自定义操作”。 - 对于可重用的工作流程,语法为
<OWNER>/<REPO>/<PATH>/<FILENAME>@<TAG OR SHA>
。 例如,octo-org/another-repo/.github/workflows/workflow.yml@v1
。 更多信息请参阅“重用工作流程”。
您可以使用
*
通配符来匹配模式。 例如,要允许以space-org
开头的组织中的所有操作 和可重用工作流程,可以指定space-org*/*
。 要允许以 octocat 开头的存储库中的所有操作 和可重用工作流程 ,可以使用*/octocat**@*
。 有关使用*
通配符的更多信息,请参阅“GitHub Actions 的工作流程语法”。注: 允许指定的操作 和可重用工作流程选项仅可用于具有 GitHub Free、GitHub Pro、组织的 GitHub Free 或 GitHub Team 计划的公共仓库。
- 对于操作,语法为
此过程演示如何将特定操作 和可重用工作流程 添加到允许列表中。
-
在 GitHub.com 的右上角,单击您的头像,然后单击 Your organizations(您的组织)。
-
在组织旁边,单击 Settings(设置)。
-
In the left sidebar, click Actions, then click General.
-
Under "Policies", select Allow OWNER, and select non-OWNER, actions and reusable workflows and add your required actions and reusable workflows to the list.
-
Click Save.
Configuring required approval for workflows from public forks
任何人都可以复刻公共仓库,然后提交建议更改仓库 GitHub Actions 工作流程的拉取请求。 虽然来自复刻的工作流程无法访问敏感数据(如密钥),但如果出于滥用目的进行修改,可能会让维护者感到烦恼。
为了帮助防止这种情况,某些外部贡献者向公共仓库提出的关于拉取请求的工作流程不会自动运行,可能需要先批准。 默认情况下,所有首次贡献者都需要批准才能运行工作流程。
注意:由 pull_request_target
事件触发的工作流程在基本分支的上下文中运行。 由于基本分支被视为受信任,因此无论审批设置如何,由这些事件触发的工作流程都将始终运行。
You can configure this behavior for an organization using the procedure below. Modifying this setting overrides the configuration set at the enterprise level.
-
在 GitHub.com 的右上角,单击您的头像,然后单击 Your organizations(您的组织)。
-
在组织旁边,单击 Settings(设置)。
-
In the left sidebar, click Actions, then click General.
-
在 Fork pull request workflows from outside collaborators(从外部贡献者复刻拉取请求工作流程)下,选择您的选项。 选项按照从限制最少到限制最多的顺序列出。
-
单击 Save(保存)以应用设置。
有关批准此政策适用的工作流程运行的更多信息,请参阅“批准公共复刻中的工作流程运行”。
Enabling workflows for private repository forks
如果您依赖于使用私有仓库的复刻,您可以配置策略来控制用户如何在 pull_request
事件上运行工作流程。 Available to private repositories only, you can configure these policy settings for organizations, or repositories.
If a policy is disabled for an organization, it cannot be enabled for repositories. If an organization enables a policy, the policy can be disabled for individual repositories.
- Run workflows from fork pull requests(从复刻拉取请求运行工作流程) - 允许用户使用具有只读权限、没有密码访问权限的
GITHUB_TOKEN
从复刻拉取请求运行工作流程。 - Send write tokens to workflows from pull requests(从拉取请求向工作流程发送写入令牌) - 允许从复刻拉取请求以使用具有写入权限的
GITHUB_TOKEN
。 - Send secrets to workflows from pull requests(从拉取请求向工作流程发送密码) - 使所有密码可用于拉取请求。
Configuring the private fork policy for an organization
- 在 GitHub.com 的右上角,单击您的头像,然后单击 Your organizations(您的组织)。
- 在组织旁边,单击 Settings(设置)。
- In the left sidebar, click Actions, then click General.
- 在 Fork pull request workflows(复刻拉取请求工作流程)下,选择您的选项。 例如:
- 单击 Save(保存)以应用设置。
Setting the permissions of the GITHUB_TOKEN
for your organization
您可以设置授予 GITHUB_TOKEN
的默认权限。 For more information about the GITHUB_TOKEN
, see "Automatic token authentication." You can choose a restricted set of permissions as the default, or apply permissive settings.
You can set the default permissions for the GITHUB_TOKEN
in the settings for your organization or your repositories. If you select a restrictive option as the default in your organization settings, the same option is selected in the settings for repositories within your organization, and the permissive option is disabled. If your organization belongs to a GitHub Enterprise account and a more restrictive default has been selected in the enterprise settings, you won't be able to select the more permissive default in your organization settings.
任何拥有仓库写入权限的人都可以通过编辑工作流程文件中的 permissions
键来修改授予 GITHUB_TOKEN
的权限,或者根据需要添加或删除权限。 更多信息请参阅 permissions
。
Configuring the default GITHUB_TOKEN
permissions
By default, when you create a new organization, GITHUB_TOKEN
only has read access for the contents
scope.
-
在 GitHub.com 的右上角,单击您的头像,然后单击 Your profile(您的个人资料)。
-
在 GitHub.com 的右上角,单击您的头像,然后单击 Your organizations(您的组织)。
-
在组织旁边,单击 Settings(设置)。
-
In the left sidebar, click Actions, then click General.
-
Under "Workflow permissions", choose whether you want the
GITHUB_TOKEN
to have read and write access for all scopes, or just read access for thecontents
scope. -
Click Save to apply the settings.
Preventing GitHub Actions from creating or approving pull requests
You can choose to allow or prevent GitHub Actions workflows from creating or approving pull requests.
By default, when you create a new organization, workflows are not allowed to create or approve pull requests.
-
在 GitHub.com 的右上角,单击您的头像,然后单击 Your profile(您的个人资料)。
-
在 GitHub.com 的右上角,单击您的头像,然后单击 Your organizations(您的组织)。
-
在组织旁边,单击 Settings(设置)。
-
In the left sidebar, click Actions, then click General.
-
Under "Workflow permissions", use the Allow GitHub Actions to create and approve pull requests setting to configure whether
GITHUB_TOKEN
can create and approve pull requests. -
Click Save to apply the settings.