gpt4 book ai didi

linux - 使用 bash 变量作为 GitHub 操作的参数

转载 作者:行者123 更新时间:2023-12-04 14:48:15 24 4
gpt4 key购买 nike

我正在调用一个 GitHub 操作,我想将参数 extra_build_args 传递给它,其值为 --build-arg CURRENT_DD_VERSION={$VER} (不在字符串中)其中 $VER 是我使用特定版本设置的 shell 变量。当我检查传入的内容时,我看到它采用了文字值 {$VER} 而不是解析变量。我设置了$VER在 Github 操作的不同(较早)步骤中。如何将shell变量的内容作为参数传入?

    - name: Get version
run: |
VER=$(cat ver.txt)
- name: Build docker image
uses: kciter/aws-ecr-action@v3
with:
//some more parameters
extra_build_args: "--build-arg CURRENT_DD_VERSION={$VER}"

最佳答案

首先检查语法:

${VER}
# not
{$VER}
在你的情况下:
extra_build_args: "--build-arg CURRENT_DD_VERSION=${VER}"
您还有文档“ Environment variables

To set custom environment variables, you need to specify the variables in the workflow file.
You can define environment variables for a step, job, or entire workflow using the jobs.<job_id>.steps[*].env, jobs.<job_id>.env, and env keywords.


这些示例将使用 $VER或者:
    extra_build_args: "--build-arg CURRENT_DD_VERSION=${{ env.VER }}"

关于linux - 使用 bash 变量作为 GitHub 操作的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69550826/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com