我无法从GitHub Action配置文件顶层定义的环境变量中访问在该操作中运行的脚本。
例如,给定以下配置文件:
name: x-pull-request
on: pull_request
env:
FOO: bar
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: does a thing
run: ./scripts/do-a-thing.sh
...以及以下脚本:
X=${FOO:default}
echo "X: $X" # X: default
配置文件中定义的FOO
环境变量对脚本不可用,正在使用默认值。
那么,在构建步骤运行的Bash脚本中如何访问环境变量?我是否缺少前缀或其他什么东西?(我知道在引用input
哈希中定义的值时需要使用INPUT_
前缀。)
GITHUB_WORKFLOW
或GITHUB_REPOSITORY
吗? - Diego Torres MilanoGITHUB_WORKFLOW
代替FOO
,结果默认值被使用了。 - pdoherty926env
而不仅仅是回显一个变量,这样它们应该可以工作。有关详细信息,请参阅:https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables - Diego Torres Milano