github-actions - 上一个作业的参考输出 GH Actions
问题描述
我正在尝试将 GitHub Actions 用于完整的管道,包括自动 SemVer 版本控制(使用标签),然后我想在构建我的 Docker 映像后使用它以使用当前版本对其进行标记。这是我用来提升版本的操作,它应该有一个 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
密钥应该允许一项工作访问上游工作,但我无法让它访问它。我需要在舞台上使用outputs
钥匙吗?version
谢谢!
解决方案
查看这个答案,您需要outputs
在创建输出的作业中定义,即
jobs:
version:
[...]
outputs:
new_tag: ${{ steps.autoversion.outputs.new_tag }}
docker:
[...] tags: ansfire/flakql:${{ needs.version.outputs.new_tag }}
推荐阅读
- swiftui - UIBezierPath / Shape 有奇怪的定位和调整大小行为
- python - 熊猫中的连接数据框给出了不同的结果
- javascript - 如何使用 Firebase、JavaScript、jQuery、Ajax、JSON 向多个设备/令牌发送移动推送通知
- julia - Julia 在脚本中共享变量
- c# - 让方法返回一些东西只是为了测试它?
- spring - springframework 中注解的植入在哪里?
- python - 彩条轴格式不正确
- laravel - 在 LARAVEL .ENV 文件中读取系统变量
- mysql - mySql 根据多列值对结果进行排序
- java - Java 最好的写法 x = Math.max(x, newX)