跳至主要内容

下载工作流工件

您可以在工件自动过期之前下载存档的工件。

谁可以使用此功能?

登录 GitHub 且对仓库具有读取权限的用户可以下载工作流工件。

默认情况下,GitHub 会存储 90 天的构建日志和工件,您可以根据仓库类型自定义此保留期。有关更多信息,请参阅 "管理仓库的 GitHub Actions 设置”。

执行这些步骤需要对仓库具有读取权限。

  1. 在 GitHub.com 上,导航到仓库的主页。

  2. 在仓库名称下方,单击 操作.

    Screenshot of the tabs for the "github/docs" repository. The "Actions" tab is highlighted with an orange outline.

  3. 在左侧边栏中,单击您要查看的工作流。

    Screenshot of the left sidebar of the "Actions" tab. A workflow, "CodeQL," is outlined in dark orange.

  4. 从工作流运行列表中,单击运行名称以查看工作流运行摘要。

  5. 在“工件”部分,单击您要下载的工件。

    Screenshot of the "Artifacts" section of a workflow run. The name of an artifact generated by the run, "artifact," is highlighted with a dark orange outline.

要了解有关 GitHub CLI 的更多信息,请参阅 "关于 GitHub CLI”。

GitHub CLI 会将每个工件下载到根据工件名称命名的单独目录中。如果只指定了一个工件,它将被提取到当前目录中。

要下载工作流运行生成的所有工件,请使用 run download 子命令。将 run-id 替换为要从中下载工件的运行 ID。如果您没有指定 run-id,GitHub CLI 会返回一个交互式菜单供您选择最近的运行。

gh run download RUN_ID

要从运行中下载特定工件,请使用 run download 子命令。将 run-id 替换为要从中下载工件的运行 ID。将 artifact-name 替换为要下载的工件的名称。

gh run download RUN_ID -n ARTIFACT_NAME

您可以指定多个工件。

gh run download RUN_ID> -n ARTIFACT_NAME-1 -n ARTIFACT_NAME-2

要下载仓库中所有运行的特定工件,请使用 run download 子命令。

gh run download -n ARTIFACT_NAME-1 ARTIFACT_NAME-2