Skip to main content

Disabling or limiting GitHub Actions for your organization

Organization owners can disable, enable, and limit GitHub Actions for an organization.

About GitHub Actions permissions for your organization

默认情况下,GitHub Actions 在 您的企业 上启用后,它 将在所有仓库和组织上启用。 You can choose to disable GitHub Actions or limit it to actions in your enterprise. 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 located within your repository and any other internal 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 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, so that people can only use local actions that exist in your enterprise.

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."

  1. 在 GitHub AE 的右上角,单击您的头像,然后单击 Your organizations(您的组织)个人资料菜单中的组织

  2. 在组织旁边,单击 Settings(设置)设置按钮

  3. In the left sidebar, click Actions.

  4. Under "Policies", select an option.

    If you choose Allow select actions, actions within your enterprise are allowed, and there are additional options for allowing other specific actions. For more information, see "Allowing select actions to run."

Set actions policy for this organization

  1. Click Save.

允许所选操作 运行

选择 Allow select actions 时,允许本地操作 ,并且还有其他选项可用于允许其他特定操作:

  • 允许 GitHub 创建的操作: 您可以允许 GitHub 创建的所有操作用于工作流程。 GitHub 创建的操作位于 actionsgithub 组织中。 更多信息请参阅 actionsgithub 组织。

  • 允许已验证的创建者执行市场操作: 此选项在您启用 GitHub Connect 并配置了 GitHub Actions 时可用。 更多信息请参阅“使用 GitHub Connect 启用对 GitHub.com 操作的自动访问”。 您可以允许工作流程使用由经过验证的创建者创建的所有 GitHub Marketplace 操作。 如果 GitHub 验证该操作的创建者为合作伙伴组织, 徽章将显示在 GitHub Marketplace 中的操作旁边。

  • 允许指定的操作: 可以将工作流程限制为使用特定组织和存储库中的操作。

    要限制对特定标记的访问或者操作 的提交 SHA,请使用工作流中使用的相同语法来选择操作。

    • 对于操作,语法为 <OWNER>/<REPO>@<TAG OR SHA>。 例如,使用 actions/javascript-action@v1.0.1 选择标记,或使用 actions/javascript-action@172239021f7ba04fe7327647b213799853a9eb89 选择 SHA。 更多信息请参阅“查找和自定义操作”。

    您可以使用 * 通配符来匹配模式。 例如,要允许以 space-org 开头的组织中的所有操作,可以指定 space-org*/*。 要允许以 octocat 开头的存储库中的所有操作 ,可以使用 */octocat**@*。 有关使用 * 通配符的更多信息,请参阅“GitHub Actions 的工作流程语法”。

此过程演示如何将特定操作 添加到允许列表中。

  1. 在 GitHub AE 的右上角,单击您的头像,然后单击 Your organizations(您的组织)个人资料菜单中的组织

  2. 在组织旁边,单击 Settings(设置)设置按钮

  3. In the left sidebar, click Actions.

  4. Under "Policies", select Allow select actions and add your required actions to the list.

    Add actions to the allow list

  5. Click 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

  1. 在 GitHub AE 的右上角,单击您的头像,然后单击 Your profile(您的个人资料)Profile photo

  2. 在 GitHub AE 的右上角,单击您的头像,然后单击 Your organizations(您的组织)个人资料菜单中的组织

  3. 在组织旁边,单击 Settings(设置)设置按钮

  4. In the left sidebar, click Actions.

  5. Under "Workflow permissions", choose whether you want the GITHUB_TOKEN to have read and write access for all scopes, or just read access for the contents scope.

    Set GITHUB_TOKEN permissions for this organization

  6. Click Save to apply the settings.