Skip to main content

Configuring custom deployment protection rules

Use GitHub Apps to automate protecting deployments with third-party systems.

谁可以使用此功能?

自定义部署保护规则在所有计划的公共存储库中可用。 要访问专用存储库或内部存储库中的自定义部署保护规则,必须使用 GitHub Enterprise。

注意

自定义部署保护规则目前为 beta 版本,可能随时更改。

About custom deployment protection rules

Custom deployment protection rules are powered by GitHub Apps. Once a deployment protection rule is configured and installed in a repository, it can be enabled for any environments in the repository.

After you enable a custom deployment protection rule on an environment, every time a workflow step targets that environment, the deployment protection rule will run automatically. For more information about targeting an environment for deployments, see Managing environments for deployment.

When a custom deployment protection rule is triggered it will wait for up to 30 days for a webhook event response before it times out and the workflow job fails.

For more information about creating your own custom deployment protection rules, see Creating custom deployment protection rules.

注意

可以在存储库中安装任意数量的基于 GitHub Apps 的部署保护规则。 但是,最多可以同时在环境中启用 6 个部署保护规则。

Using existing custom deployment protection rules

You can choose to create your own custom deployment protection rules or you may use any existing custom deployment protection rules.

The following is a list of official partner implementations for deployment protection rules.

Prerequisites

In order for a custom deployment protection rule to be available to all environments in a repository, you must first install the custom deployment protection rule on the repository. For more information, see 安装自己的 GitHub 应用.

After a custom deployment protection rule has been installed in a repository, it must be enabled for each environment where you want the rule to apply.

Enabling custom deployment protection rules for the environment

  1. 在 GitHub 上,导航到存储库的主页面。

  2. 在存储库名称下,单击 “设置”。 如果看不到“设置”选项卡,请选择“”下拉菜单,然后单击“设置”。

    存储库标头的屏幕截图,其中显示了选项卡。 “设置”选项卡以深橙色边框突出显示。

  3. 在左侧边栏中,单击“环境”。

  4. Select the environment you want to configure.

  5. Under "Deployment protection rules," check the box next to each custom deployment protection rule you want to enable for the environment.

  6. Click Save protection rules.

Once a custom deployment protection rule has been enabled for an environment, it will automatically run whenever a workflow reaches a job that references the environment. You can see the results of an approval or rejection for your deployment by reviewing the details of the deployment. For more information, see Reviewing deployments.