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

时间:2019-11-28 10:34:41

标签: github-actions

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

该操作的值为空白,因此评估为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 个答案:

答案 0 :(得分:0)

除了一个小细节外,您几乎都理解对了-在尝试访问outputs时,您跳过了is-release-candidate部分-正确的版本: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 :(得分:-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...