Skip to main content

Enabling GitHub Actions with Azure Blob storage

You can enable GitHub Actions on GitHub Enterprise Server and use Azure Blob storage to store data generated by workflow runs.

谁可以使用此功能?

Site administrators can enable GitHub Actions and configure enterprise settings.

关于 GitHub Actions

的外部存储

GitHub Actions 使用外部 blob 存储来存储工作流运行生成的数据。 存储的数据包括工作流日志缓存和用户上传的生成项目。有关详细信息,请参阅“Getting started with GitHub Actions for GitHub Enterprise Server”。

可通过两个选项将 GitHub Enterprise Server 配置为连接到外部存储提供程序:

  • OpenID Connect (OIDC)
  • 使用机密的传统基于凭据的身份验证

建议尽可能使用 OIDC,因为不需要为存储提供程序创建或管理敏感且生存期较长的凭据机密,也不需要冒暴露这些机密的风险。 使用 OIDC 定义信任后,云存储提供程序会自动向 你的 GitHub Enterprise Server 实例 颁发短期访问令牌,这些令牌会自动过期。

Prerequisites

Before enabling GitHub Actions, make sure you have completed the following steps:

  • Create your Azure storage account for storing workflow data. GitHub Actions stores its data as block blobs, and two storage account types are supported:

    • A general-purpose storage account (also known as general-purpose v1 or general-purpose v2) using the standard performance tier.

      Warning: Using the premium performance tier with a general-purpose storage account is not supported. The standard performance tier must be selected when creating the storage account, and it cannot be changed later.

    • A BlockBlobStorage storage account, which uses the premium performance tier.

    For more information on Azure storage account types and performance tiers, see the Azure documentation.

  • 查看 GitHub Actions 的硬件要求。 有关详细信息,请参阅“Getting started with GitHub Actions for GitHub Enterprise Server”。

  • 必须为 你的 GitHub Enterprise Server 实例 的域配置 TLS。 有关详细信息,请参阅“Configuring TLS”。

    注意: 我们强烈建议您在 GitHub Enterprise Server 上配置 TLS,并有信任的机构签名的证书。 虽然自签名证书可以工作,但自托管的运行器需要额外的配置,不推荐用于生产环境。

  • 如果在 你的 GitHub Enterprise Server 实例 上配置了 HTTP 代理服务器:

  • 必须将 .localhost127.0.0.1::1 添加到“HTTP 代理排除”**** 列表(以此顺序)。

  • 如果外部存储位置不可路由,则还必须将外部存储 URL 添加到排除列表中。

有关更改代理设置的详细信息,请参阅“Configuring an outbound web proxy server”。

  • 如果使用 OIDC 连接到存储提供商,则必须将 你的 GitHub Enterprise Server 实例 上的以下 OIDC 令牌服务 URL 公开到公共 Internet:

    https://HOSTNAME/_services/token/.well-known/openid-configuration
    https://HOSTNAME/_services/token/.well-known/jwks
    

    这确保存储提供商可以联系 你的 GitHub Enterprise Server 实例 进行身份验证。

To configure GitHub Enterprise Server to use OIDC with an Azure storage account, you must first register a Microsoft Entra ID (previously known as Azure AD) application with OIDC credentials, then configure your storage account, and finally configure GitHub Enterprise Server to access the storage container using the Entra ID.

1. Register an Entra ID application

  1. Log in to the Microsoft Entra admin center.

  2. Register a new application in Entra ID. For more information, see Quickstart: Register an application with the Microsoft identity platform on Microsoft Learn.

  3. In your Entra ID application, under "Essentials", take note of the values for "Application (client) ID" and "Directory (tenant) ID". These values are used later.

    Screenshot of the "Overview" page in Entra ID. The first four items in the "Essentials" section are highlighted with an orange outline.

  4. In your Entra ID application, under "Manage", click Certificates & secrets, select the Federated credentials tab, then click Add credential.

    Screenshot of the "Federated credentials" page in Entra ID. The "Certificates & secrets" tab, the "Federated credentials" tab, and the "Add credential" button are highlighted with orange outlines.

  5. Enter the following details for the credential:

    1. For "Federated credential scenario", select Other issuer.

    2. For "Issuer", enter https://HOSTNAME/_services/token, where HOSTNAME is the public hostname for 你的 GitHub Enterprise Server 实例. For example, https://my-ghes-host.example.com/_services/token.

    3. For "Subject identifier", enter the public hostname for 你的 GitHub Enterprise Server 实例. For example, my-ghes-host.example.com.

      Note: The subject identifier must only have the hostname of 你的 GitHub Enterprise Server 实例, and must not include the protocol.

    4. For "Name", enter a name for the credential.

    5. Click Add.

2. Configure your storage account

  1. In the Microsoft Azure portal, navigate to your storage account.

  2. Click Access Control (IAM), then click Add, and select Add role assignment.

  3. For the role, select "Storage Blob Data Owner", then click Next.

  4. For members, click Select members, and then search for and select the name of the Entra ID application you created earlier. Click Select.

  5. Click Review + assign, review the role assignment, then click Review + assign again.

  6. In the left menu, under "Settings", click Endpoints.

  7. Under "Blob service", take note of the value for "Blob service", specifically the blob endpoint suffix. This is the value after https://<storageaccountname>.blob. It is typically core.windows.net, but might vary depending on your Azure region or account type.

    For example, if your blob service URL is https://my-storage-account.blob.core.windows.net, the blob endpoint suffix is core.windows.net.

    Note your storage account name and blob endpoint suffix, as these values are used later.

3. Configuring GitHub Enterprise Server to connect to Entra ID using OIDC

  1. 在 GitHub Enterprise Server 上的管理帐户中,在任一页面的右上角,单击

  2. 如果你尚未在“站点管理员”页上,请在左上角单击“站点管理员”。

  3. 在“ 站点管理”边栏中,单击“管理控制台”。

  4. 在“设置”边栏中,单击“操作”。

  5. 在“GitHub Actions”下,选择“启用 GitHub Actions”。

  6. 在“项目和日志存储”下的“Azure Blob 存储”旁,单击“设置”。

  7. Under "Authentication", select OpenID Connect (OIDC), and enter the values for your storage that you noted down in the previous procedures:

    • Entra ID tenant ID
    • Entra ID client ID
    • Azure storage account name
    • Azure blob endpoint suffix
  8. 单击“测试存储设置”按钮验证存储设置。

    如果在验证存储设置时出现任何错误,请检查存储提供程序设置并重试。

  9. 在“设置”边栏下,单击“保存设置”。

    注意:保存 管理控制台 中的设置会重启系统服务,这可能会导致用户可察觉的停机时间。

  10. 等待配置运行完毕。

Enabling GitHub Actions with Azure Blob storage using a connection string

  1. 在 GitHub Enterprise Server 上的管理帐户中,在任一页面的右上角,单击

  2. 如果你尚未在“站点管理员”页上,请在左上角单击“站点管理员”。

  3. 在“ 站点管理”边栏中,单击“管理控制台”。

  4. 在“设置”边栏中,单击“操作”。

  5. 在“GitHub Actions”下,选择“启用 GitHub Actions”。

  6. 在“项目和日志存储”下的“Azure Blob 存储”旁,单击“设置”。

  7. Under "Authentication", select Credentials-based, and enter your Azure storage account's connection string. For more information on getting the connection string for your storage account, see the Azure documentation.

  8. 单击“测试存储设置”按钮验证存储设置。

    如果在验证存储设置时出现任何错误,请检查存储提供程序设置并重试。

  9. 在“设置”边栏下,单击“保存设置”。

    注意:保存 管理控制台 中的设置会重启系统服务,这可能会导致用户可察觉的停机时间。

  10. 等待配置运行完毕。

后续步骤

配置运行成功完成后,GitHub Actions 将在 你的 GitHub Enterprise Server 实例 上启用。 对于后续步骤,例如管理 GitHub Actions 访问权限和添加自托管运行器,请返回到“Getting started with GitHub Actions for GitHub Enterprise Server”。