从文件创建 Github Actions 选择输入选项

发布于 2025-01-14 10:15:06 字数 400 浏览 4 评论 0原文

目前,我们正在运行手动工作流程,以便将我们的产品部署到生产环境中。我们只有一项输入,就可以选择需要部署的品牌。

它包括诸如此类的选项

on:
  workflow_dispatch:
    inputs:
      dst:
        type: choice
        description: Select destination brand
        required: true
        options:
          - A
          - B
          - C

的问题是,是否可以从文件(例如我们项目中的文本文件)读取此选项?我看了看,但没有看到其他人的解决方案。

太感谢了!

Right now, we're running a manual workflow in order to deploy our product to production. We have one input and we can choose our brand which needs to be deployed.

It's including options like

on:
  workflow_dispatch:
    inputs:
      dst:
        type: choice
        description: Select destination brand
        required: true
        options:
          - A
          - B
          - C

and so on

My question is, is it possible to read this options from a file (like a text file which is in our project)? I looked at it but I couldn't see a solution from others.

Thank you so much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野稚 2025-01-21 10:15:06

不 - 恐怕目前不可能进行动态工作流程配置。

我个人使用的解决方案是使用 workflow_dispatch 事件,具有正确的输入选项。

您可以使用一个脚本在本地读取包含所有选项的文件并让您在本地选择所需的选项,而不是在网络上手动触发它,然后它将使用所选输入触发 workflow_dispatch 事件。

如果您不希望本地解析,另一种选择是将输入作为常规字符串,然后在工作流程中添加一个步骤,该步骤将在actions/checkout之后读取文件并检查它是否是一个有效的选项。

No - it's not possible to have dynamic workflow configurations at the moment, I'm afraid.

The solution I personally use is to trigger this type of workflow using workflow_dispatch event with proper input options.

Instead of triggering it manually on web, you can have a script that locally reads the file with all options and let you pick desired option locally, then it will trigger workflow_dispatch event with the selected input.

Another alternative if you don't want local parsing will be to make input as regular string and then add a step in your workflow that will read a file after actions/checkout and check if it's a valid option.

超可爱的懒熊 2025-01-21 10:15:06

一种黑客可能是使用第二个工作流程(wkfl2)来维护workflow_dispatch(wkfl1)选项。类似于以下序列:

  • 您的存储库中有一个带有选项 [A、B、C] 的文本文件“dst.txt”。
  • 有人将选项“D”推送到“dst.txt”。
  • wkfl2 运行,更新 wkfl1 中的选项列表。

One hack could be using a second workflow (wkfl2) to maintain the workflow_dispatch (wkfl1) options. Something like the following sequence:

  • There is a text file 'dst.txt' in your repo with options [A, B, C].
  • Someone pushes option 'D' to 'dst.txt'.
  • wkfl2 runs, updating the list of options in wkfl1.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文