【问题标题】:Combine dynamic Github Workflow matrix with input values and predefined values将动态 Github Workflow 矩阵与输入值和预定义值相结合
【发布时间】:2021-12-15 05:52:13
【问题描述】:

我有一个有效的 GitHub 工作流,它使用矩阵并构建所有定义的产品。

name: Build

on:
  push:
    tags:
      - "*"
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
       product: [yellow, green, black]
       limits: [10,20,50,100]

    steps:
      - uses: actions/checkout@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    ...

现在希望能够手动触发构建过程并使用输入值仅构建我想要的产品。我可以在 Github 界面上输入值,但是看起来使用它们的语法不正确。

构建:.github#L1 评估作业“构建”的“策略”时出错。 .github/workflows/build.yml(第 27 行,第 18 列):意外值 'yellow',.github/workflows/build.yml(第 28 行,第 17 列):出乎意料 值'50'

此外,如何将所有预定义产品的先前自动构建与通过输入在一个工作流中手动完成的构建相结合?

name: Build

on:
  push:
    tags:
      - "*"
  workflow_dispatch:
    inputs:
      product:
        description: "Product"
        default: "yellow"
      limit:
        description: "Limit"
        default: "50"

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        product: ${{ github.event.inputs.product}}
        limits: ${{ github.event.inputs.limit }}

        # product: [yellow, green, black]
        # limits: [10,20,50,100]

    steps:
      - uses: actions/checkout@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    ...

【问题讨论】:

  • 你有没有想过解决这个问题?

标签: github github-actions


【解决方案1】:

您输入的名称好像有错字(应该是product 而不是edition)?

 strategy:
      matrix:
        edition: ${{ github.event.inputs.product }}

【讨论】:

  • 谢谢,但这不是问题。
猜你喜欢
  • 1970-01-01
  • 2022-08-10
  • 2022-01-17
  • 2016-05-27
  • 2017-10-12
  • 2018-10-31
  • 1970-01-01
  • 1970-01-01
  • 2021-05-07
相关资源
最近更新 更多