# 删除工作流程构件

您可以在工件在 GitHub Actions 上过期之前删除工件来回收已使用的 GitHub 存储空间。

> \[!NOTE]
> GitHub Enterprise Server 目前不支持 GitHub 托管的运行器。

## 删除构件

> \[!WARNING]
> 工件一旦删除，便无法恢复。

执行这些步骤需要对仓库的写入访问权限。

默认情况下， GitHub 将生成日志和项目存储 90 天，并且可以自定义此保留期。 有关详细信息，请参阅“[管理存储库的GitHub Actions设置](/zh/enterprise-server@3.22/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-repository)”。

1. 在 GitHub 上，导航到存储库的主页面。
2. 在仓库名称下，单击“<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-play" aria-label="play" role="img"><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> Actions”\*\*\*\*。

   ![“github/docs”存储库的选项卡的屏幕截图。 “操作”选项卡以橙色边框突出显示。](/assets/images/help/repository/actions-tab-global-nav-update.png)
3. 在左侧边栏中，单击您想要查看的工作流程。

   ![“操作”选项卡的左侧边栏的屏幕截图。工作流“CodeQL”以深橙色标出。](/assets/images/help/actions/superlinter-workflow-sidebar.png)
4. 在工作流运行列表中，单击运行的名称以查看工作流运行摘要。
5. 在“**Artifacts**”下，单击要删除的工件旁边的 <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-trash" aria-label="Remove artifact ARTIFACT-NAME" role="img"><path d="M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z"></path></svg>。

   ![屏幕截图显示工作流运行期间创建的工件。 垃圾桶图标，用于删除工件，带深橙色轮廓。](/assets/images/help/repository/actions-delete-artifact-updated.png)

## 设置制品的存储期限

可在仓库、组织和企业级配置构件和日志的保留期。 有关详细信息，请参阅 [管理存储库的GitHub Actions设置](/zh/enterprise-server@3.22/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#setting-the-artifact-and-log-retention-period-for-a-repository) 和 [为组织中的 GitHub Actions 构件和日志配置保留期](/zh/enterprise-server@3.22/organizations/managing-organization-settings/configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-organization)。

也可以在工作流中使用 `actions/upload-artifact` 操作自定义个别工件的保留期。 有关详细信息，请参阅“[使用工作流工件存储和共享数据](/zh/enterprise-server@3.22/actions/tutorials/store-and-share-data#configuring-a-custom-artifact-retention-period)”。

## 查找构件的到期日期

您可以使用 API 确认构件计划删除的日期。 有关详细信息，请参阅 REST API 返回的 `expires_at` 值。 有关详细信息，请参阅“[GitHub Actions 构件的 REST API 终结点](/zh/enterprise-server@3.22/rest/actions/artifacts)”。

## 已删除的工作流运行记录中的产物

删除某个工作流运行时，也会从存储中删除与该运行关联的所有工件。 可以使用 GitHub Actions UI、REST API 或使用 GitHub CLI 删除工作流运行，请参阅“[删除工作流程运行](/zh/enterprise-server@3.22/actions/how-tos/manage-workflow-runs/delete-a-workflow-run)”、[删除工作流运行](/zh/enterprise-server@3.22/rest/actions/workflow-runs?apiVersion=2022-11-28#delete-a-workflow-run)或 [gh run delete](https://cli.github.com/manual/gh_run_delete)。