GitHub动作中的环境变量未正确插值
在(可重复使用的)工作流程的开头
env:
STAGING_GCR_PROJECT: my-project-id
,在Slack中使用它时,
slack_staging_success:
needs: build_staging
runs-on: ubuntu-latest
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
env:
STAGING_IMAGE: "gcr.io/$STAGING_GCR_PROJECT/${{ inputs.image_name }}:${{ inputs.image_tag }}"
steps:
- name: slack success for staging
uses: rtCamp/action-slack-notify@v2
env:
SLACK_ICON: $SLACK_ICON_SUCCESS
SLACK_COLOR: green
SLACK_MESSAGE: "STAGING image ${{ env.STAGING_IMAGE }} was built / pushed with SUCCESS"
消息插值为
登台图像gcr.io/qulstaging_gcr_project/echo-server:1.0.2无法构建
为什么$ staging_gcr_project
不正确地进行了插补?
In the beginning of a (re-usable) workflow
env:
STAGING_GCR_PROJECT: my-project-id
and when using it
slack_staging_success:
needs: build_staging
runs-on: ubuntu-latest
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
env:
STAGING_IMAGE: "gcr.io/$STAGING_GCR_PROJECT/${{ inputs.image_name }}:${{ inputs.image_tag }}"
steps:
- name: slack success for staging
uses: rtCamp/action-slack-notify@v2
env:
SLACK_ICON: $SLACK_ICON_SUCCESS
SLACK_COLOR: green
SLACK_MESSAGE: "STAGING image ${{ env.STAGING_IMAGE }} was built / pushed with SUCCESS"
In Slack the message interpolates as
STAGING image gcr.io/$STAGING_GCR_PROJECT/echo-server:1.0.2 failed to be built
Why isn't $STAGING_GCR_PROJECT
interpolated correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目前不支持ENV变量Ins Inv。
docs> docs 提到:
It is not supported at the moment, to have env variable inside env.
The docs on env mentions it:
为了使用工作流环境变量,请使用前缀
env。
In order to use workflow environment variables, use the prefix
env.
and enclose it in${{ }}
just like you did with the inputs: