简体   繁体   English

如何在 github 操作中为手动触发 (workflow_dispatch) 工作流提供多个输入?

[英]How to provide multiple inputs for a manually triggered (workflow_dispatch) workflow in github actions?

I have a requirement to enter multiple inputs using workflow_dispatch and use matrix to play with them.我需要使用 workflow_dispatch 输入多个输入并使用矩阵来处理它们。

Fox Example:狐狸示例:

I have 10 repositories.我有 10 个存储库。 When user runs a workflow manually, he/she will need to provide 5/6 repositories as input at a time.当用户手动运行工作流时,他/她需要一次提供 5/6 个存储库作为输入。 I can see workflow_dispatch option, currently supports only string as an input.我可以看到 workflow_dispatch 选项,目前仅支持字符串作为输入。 Is there anyway to deal with this situation using github actions?无论如何使用 github 动作来处理这种情况?

So workflow_dispatch events actually support 3 input types;所以workflow_dispatch事件实际上支持 3 种输入类型; choice , environment , boolean . choiceenvironmentboolean

I don't think you'll be able to pass inputs for matrix tasks that expect a list of values though (you can definitely do it for single values我不认为您将能够为期望值列表的矩阵任务传递输入(您绝对可以为单个值执行此操作

If there are only several inputs you might be able to use multiple booleans and conditionally run jobs or steps.如果只有几个输入,您可能能够使用多个booleans并有条件地运行作业或步骤。 Not as clean clean but will do the job.没有那么干净,但可以完成这项工作。

on:
  workflow_dispatch:
    inputs:
      repo_1:
        type: boolean
        default: false
        description: Use Repo 1?
      repo_2:
        type: boolean
        default: false
        description: Use Repo 2?
jobs:
  repo-1-job:
    name: Repo 1 Job
    runs-on: ubuntu-latest
    if: github.event.inputs.repo_1 == 'true'
    steps:
      - run: echo "some repo 1 job"
  
  repo-2-job:
    name: Repo 2 Job
    runs-on: ubuntu-latest
    if: github.event.inputs.repo_2 == 'true'
    steps:
      - run: echo "some repo 2 job"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM