[英]pass Github secrets to a docker github action
Hi my devoted and beloved developers!嗨,我忠实且敬爱的开发人员!
Today I face trouble trying to transmit GitHub secrets to a docker GitHub action in order to use this variable in the container.今天,我在尝试将 GitHub 机密传输到 docker GitHub 操作以在容器中使用此变量时遇到了麻烦。 I already have defined for the project the secret what_a_secret
for the key CHUT
.我已经为这个项目的秘密定义what_a_secret
为重点CHUT
。
Here is what I currently have:这是我目前拥有的:
name: Continious Delivery
on: [push]
jobs:
myjob:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Docker Run Action
uses: addnab/docker-run-action@v3
env:
CHUT: ${{ secrets.CHUT }}
with:
image: amazon/aws-glue-libs:glue_libs_1.0.0_image_01
options:
--env CHUT=$CHUT
-v ${{ github.workspace }}:/workspace
run:
echo CHUT=$CHUT
This just print CHUT=$CHUT
instead of CHUT=what_a_secret
.这只是打印CHUT=$CHUT
而不是CHUT=what_a_secret
。
I also tried to do something like this:我也尝试做这样的事情:
--env CHUT=${{ secrets.CHUT }}
And this:还有这个:
run:
echo CHUT=${{ secrets.CHUT }}
But the lasts solution returns nothing at all.但是 lasts 解决方案根本不返回任何内容。
Your help would be warmly welcomed您的帮助将受到热烈欢迎
EDIT: the documentation " Configure GitHub Actions " do not work to pass environment variables to a container.编辑:文档“配置 GitHub 操作”无法将环境变量传递给容器。
The final anwswer is: I made my code cleaner and did this :最后的答案是:我让我的代码更干净并做到了这一点:
name: Continious Delivery
on: [push]
jobs:
myjob:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Docker Run Action
uses: addnab/docker-run-action@v3
with:
image: amazon/aws-glue-libs:glue_libs_1.0.0_image_01
options:
--e CHUT=${{ secrets.CHUT }}
-v ${{ github.workspace }}:/workspace
run:
echo "CHUT=$CHUT"
output is CHUT=***
because Github is smart enough to not print a secret in the terminal.输出是CHUT=***
因为 Github 足够聪明,不会在终端中打印秘密。 But the docker read the secret correctly.但是 docker 正确地读取了这个秘密。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.