【问题标题】:Reference output from previous job GH Actions上一个作业的参考输出 GH Actions
【发布时间】:2021-10-06 10:35:28
【问题描述】:

我正在尝试将 GitHub Actions 用于完整的管道,包括自动 SemVer 版本控制(使用标签),然后我想在构建我的 Docker 映像后使用它以使用当前版本对其进行标记。这是我用来提升版本的action,它应该有一个 new_tag 输出但我无法引用它,这就是我正在尝试的:

jobs:
  setup:
    ...
  version:
    needs: [setup]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: '0'
    - name: Bump version and push tag
      uses: anothrNick/github-tag-action@1.26.0
      id: autoversion
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        WITH_V: true
  sonar:
    ...
  anchore:
    ...
  docker:
    needs: [setup, version]
    steps:
      ...
      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: ansfire/flaskql:${{ needs.version.autoversion.outputs.new_tag }}

从我读到的使用needs 键应该允许一个作业访问上游作业,但我无法让它访问它。在version 阶段我需要outputs 密钥吗?谢谢!

【问题讨论】:

    标签: github-actions github-actions-artifacts


    【解决方案1】:

    查看这个answer,您需要在创建输出的作业中定义outputs,即

    jobs:
      version:
        [...]
        outputs:
          new_tag: ${{ steps.autoversion.outputs.new_tag }}
    
      docker:
        [...] tags: ansfire/flakql:${{ needs.version.outputs.new_tag }}
    

    【讨论】:

    • 非常感谢!
    猜你喜欢
    • 2021-12-21
    • 2022-11-02
    • 2021-09-23
    • 2021-08-28
    • 1970-01-01
    • 2022-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多