Skip to main content

禁用或限制组织的 GitHub Actions

你可启用、禁用和限制组织的 GitHub Actions。

谁可以使用此功能?

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

Note

GitHub-hosted runners are not currently supported on GitHub Enterprise Server. You can see more information about planned future support on the GitHub public roadmap.

About GitHub Actions permissions for your organization

By default, after GitHub Actions is enabled on GitHub Enterprise Server, it is enabled on all repositories and organizations. You can choose to disable GitHub Actions or limit it to actions in your enterprise. For more information about GitHub Actions, see "Writing workflows."

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 public or internal repository. You can disable GitHub Actions for all repositories in your organization. When you disable GitHub Actions, no workflows run in your repository.

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. In the upper-right corner of GitHub, select your profile photo, then click Your organizations.

  2. Next to the organization, click Settings.

  3. In the left sidebar, click Actions, then click General.

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

  5. Click Save.

Allowing select actions to run

When you choose Allow select actions, local actions are allowed, and there are additional options for allowing other specific actions:

Note

You might not be able to manage these settings if your organization has an overriding policy or is managed by an enterprise that has overriding policy. For more information, see "Disabling or limiting GitHub Actions for your organization" or "Enforcing policies for GitHub Actions in your enterprise."

  • Allow actions created by GitHub: You can allow all actions created by GitHub to be used by workflows. Actions created by GitHub are located in the actions and github organizations. For more information, see the actions and github organizations.

  • Allow Marketplace actions by verified creators: This option is available if you have GitHub Connect enabled and configured with GitHub Actions. For more information, see "Enabling automatic access to GitHub.com actions using GitHub Connect." You can allow all GitHub Marketplace actions created by verified creators to be used by workflows. When GitHub has verified the creator of the action as a partner organization, the badge is displayed next to the action in GitHub Marketplace.

  • Allow specified actions: You can restrict workflows to use actions in specific organizations and repositories. Specified actions cannot be set to more than 1000.

    To restrict access to specific tags or commit SHAs of an action, use the same syntax used in the workflow to select the action.

    • For an action, the syntax is OWNER/REPOSITORY@TAG-OR-SHA. For example, use actions/javascript-action@v1.0.1 to select a tag or actions/javascript-action@a824008085750b8e136effc585c3cd6082bd575f to select a SHA. For more information, see "Using pre-written building blocks in your workflow."

    You can use the * wildcard character to match patterns. For example, to allow all actions in organizations that start with space-org, you can specify space-org*/*. To allow all actions in repositories that start with octocat, you can use */octocat**@*. For more information about using the * wildcard, see "Workflow syntax for GitHub Actions."

This procedure demonstrates how to add specific actions to the allow list.

  1. In the upper-right corner of GitHub, select your profile photo, then click Your organizations.
  2. Next to the organization, click Settings.
  3. In the left sidebar, click Actions, then click General.
  4. Under "Policies", select Allow select actions and add your required actions to the list.
  5. Click Save.

Limiting the use of self-hosted runners

There is no guarantee that self-hosted runners for GitHub Enterprise Server will be hosted on ephemeral, clean virtual machines. As a result, they may be compromised by untrusted code in a workflow.

Similarly, anyone who can fork the repository and open a pull request (generally those with read access to the repository) can compromise the self-hosted runner environment, including gaining access to secrets and the GITHUB_TOKEN which, depending on its settings, can grant write access to the repository. Although workflows can control access to environment secrets by using environments and required reviews, these workflows are not run in an isolated environment and are still susceptible to the same risks when run on a self-hosted runner.

For these and other reasons, you may decide to prevent people creating self-hosted runners at the repository level.

Note

If your organization belongs to an enterprise, creation of self-hosted runners at the repository level may have been disabled as an enterprise-wide setting. If this has been done, you cannot enable repository-level self-hosted runners in your organization settings. For more information, see "Enforcing policies for GitHub Actions in your enterprise."

If a repository already has self-hosted runners when you disable their use, these will be listed with the status "Disabled" and they will not be assigned any new workflow jobs.

Screenshot of the "Runners" list showing a self-hosted runner with the status "Disabled."

Note

When creation of repository-level self-hosted runners is disabled, workflows can still access self-hosted runners at the enterprise or organization level.

  1. In the upper-right corner of GitHub, select your profile photo, then click Your organizations.
  2. Next to the organization, click Settings.
  3. In the left sidebar, click Actions, then click General.
  4. Under "Runners," use the dropdown menu to choose your preferred setting:
    • All repositories - self-hosted runners can be used for any repository in your organization.
    • Selected repositories - self-hosted runners can only be used for the repositories you select.
    • Disabled - self-hosted runners cannot be created at the repository level.
  5. If you choose Selected repositories:
    1. Click .
    2. Select the check boxes for the repositories for which you want to allow self-hosted runners.
    3. Click Select repositories.

Enabling workflows for private repository forks

If you rely on using forks of your private repositories, you can configure policies that control how users can run workflows on pull_request events. Available to private and internal repositories only, you can configure these policy settings for your enterprise, organizations, or repositories.

If a policy is disabled for an enterprise, it cannot be enabled for organizations. 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 - Allows users to run workflows from fork pull requests, using a GITHUB_TOKEN with read-only permission, and with no access to secrets.
  • Send write tokens to workflows from pull requests - Allows pull requests from forks to use a GITHUB_TOKEN with write permission.
  • Send secrets to workflows from pull requests - Makes all secrets available to the pull request.
  • Require approval for fork pull request workflows - Workflow runs on pull requests from collaborators without write permission will require approval from someone with write permission before they will run.

Configuring the private fork policy for an organization

  1. In the upper-right corner of GitHub, select your profile photo, then click Your organizations.
  2. Next to the organization, click Settings.
  3. In the left sidebar, click Actions, then click General.
  4. Under Fork pull request workflows, select your options.
  5. Click Save to apply the settings.

Setting the permissions of the GITHUB_TOKEN for your organization

You can set the default permissions granted to the 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.

Anyone with write access to a repository can modify the permissions granted to the GITHUB_TOKEN, adding or removing access as required, by editing the permissions key in the workflow file. For more information, see permissions.

Configuring the default GITHUB_TOKEN permissions

By default, when you create a new organization, the setting is inherited from what is configured in the enterprise settings.

  1. In the top right corner of GitHub, click your profile photo, then click Your profile.

    Screenshot of the dropdown menu under @octocat's profile picture. "Your profile" is outlined in dark orange.

  2. In the upper-right corner of GitHub, select your profile photo, then click Your organizations.

  3. Next to the organization, click Settings.

  4. In the left sidebar, click Actions, then click General.

  5. Under "Workflow permissions", choose whether you want the GITHUB_TOKEN to have read and write access for all permissions (the permissive setting), or just read access for the contents and packages permissions (the restricted setting).

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

  1. In the top right corner of GitHub, click your profile photo, then click Your profile.

    Screenshot of the dropdown menu under @octocat's profile picture. "Your profile" is outlined in dark orange.

  2. In the upper-right corner of GitHub, select your profile photo, then click Your organizations.

  3. Next to the organization, click Settings.

  4. In the left sidebar, click Actions, then click General.

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

  6. Click Save to apply the settings.

Managing GitHub Actions cache storage for your organization

Organization administrators can view and manage GitHub Actions cache storage for all repositories in the organization.

Viewing GitHub Actions cache storage by repository

For each repository in your organization, you can see how much cache storage a repository is using, the number of active caches, and if a repository is near the total cache size limit. For more information about the cache usage and eviction process, see "Caching dependencies to speed up workflows."

  1. In the top right corner of GitHub, click your profile photo, then click Your profile.

    Screenshot of the dropdown menu under @octocat's profile picture. "Your profile" is outlined in dark orange.

  2. In the upper-right corner of GitHub, select your profile photo, then click Your organizations.

  3. Next to the organization, click Settings.

  4. In the left sidebar, click Actions, then click Caches.

  5. Review the list of repositories for information about their GitHub Actions caches. You can click on a repository name to see more detail about the repository's caches.

Configuring GitHub Actions cache storage for your organization

By default, the total cache storage that GitHub Actions uses on the external storage for GitHub is limited to a maximum of 10 GB per repository, and the maximum allowed size that can be set for a repository is 25 GB.

You can configure the size limit for GitHub Actions caches that will apply to each repository in your organization. The cache size limit for an organization cannot exceed the cache size limit set in the enterprise policy. Repository admins will be able to set a smaller limit in their repositories.

  1. In the top right corner of GitHub, click your profile photo, then click Your profile.

    Screenshot of the dropdown menu under @octocat's profile picture. "Your profile" is outlined in dark orange.

  2. In the upper-right corner of GitHub, select your profile photo, then click Your organizations.

  3. Next to the organization, click Settings.

  4. In the left sidebar, click Actions, then click General.

  5. Under Cache size limit, enter a new value.

  6. Click Save to apply the change.