【问题标题】:How to remove github actions artifact produced during runtime如何删除在运行时生成的 github 操作工件
【发布时间】:2022-12-08 08:10:37
【问题描述】:

在工作流执行期间,我生成了几个工件,但在成功构建后我不再需要它们,我想清理它们,因为我只是暂时需要它们。

- name: Make artifact available to use
        uses: actions/upload-artifact@v2
        with:
          name: setup
          path: setup.yml

作为不同工作的一部分,我需要工件,所以我也有

- name: Download yaml file
        uses: actions/download-artifact@v2
        with:
          name: setup

我如何在工作流程中添加一个步骤(在我的例子中是最后一步)来删除这些在运行时产生的工件?

【问题讨论】:

标签: github-actions github-actions-self-hosted-runners github-actions-artifacts


【解决方案1】:

delete artifact actions on the marketplace 可以帮助你。

this one 示例:

steps:
- uses: actions/checkout@v3

- run: echo hello > world.txt

- name: Make artifact available to use
  uses: actions/upload-artifact@v2
  with:
    name: setup
    path: world.txt

# delete-artifact
- uses: geekyeggo/delete-artifact@v1
  with:
    name: setup

我做了一个工作流运行示例here如果你想看看.

【讨论】:

  • 谢谢。这很棒,但不幸的是我不能在我的组织中使用它。
  • 如果您担心在您的组织内部使用开源操作,您可以创建自己的操作或可重用的工作流程,使用 Github API:https://api.github.com/repos/OWNER/REPO/actions/artifacts/$idexample with a bash script doing it
【解决方案2】:

作为访问 GitHub 的 python API 的一部分。 examples 之一提供了一个用于构建蜡状存储库工件的工具。

【讨论】:

    猜你喜欢
    • 2023-01-05
    • 2021-02-04
    • 1970-01-01
    • 2019-08-19
    • 1970-01-01
    • 2022-10-19
    • 1970-01-01
    • 2021-05-02
    • 2023-04-03
    相关资源
    最近更新 更多