如何在 Github Action 工作流程中将操作的输出用作if条件表达式?

4

我正在构建一个工作流程,在其中一个操作提供了工作流程中一个步骤的条件。我该如何使用这个值?

来自该操作的值为空,因此将被解释为false,导致没有任何内容被部署...

jobs:
  build:
    steps:
      - id: verify
        name: verify if artifact is eligable for deployment
        uses: my.org/my.action.group/my.action.path@my.branch
      - name: release candidate
        run: echo release candidate - "${{ steps.verify.is-release-candidate }}"
      - name: deploy
        run: ...
        if: steps.verify.is-release-candidate

调试版本发布候选:

Run echo release candidate - ""
release candidate - 

action.yml:

....
outputs:
  is-release-candidate:
    description: true if this new version can be auto deployed, false if not
2个回答

2
你的思路几乎正确,只是漏掉了一个小细节——在尝试访问“is-release-candidate”时,你跳过了“outputs”部分。正确的版本应该是: steps.<id>.outputs.<name>
- name: release candidate
  run:  echo "release candidate - ${{ steps.verify.outputs.is-release-candidate }}"
- name: deploy
  run:  ...
  if:   steps.verify.outputs.is-release-candidate

-1
尝试使用这个代码。你会在find_output变量中得到输出结果,然后在下一步中使用它。
jobs:
  build:
    steps:
      - id: verify
        name: verify if artifact is eligable for deployment
        uses: my.org/my.action.group/my.action.path@my.branch
        register : find_output
      - debug:
        var: find_output
      - name: deploy
        if: find_output.<use the key to validate>, yaml: A SEQUENCE WAS EXPECTED...

我想看到“register”、“debug”和“yaml”的解释,除非它们是GitHub工作流语法早期版本的产物。 - Lee Meador

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接