简体   繁体   中英

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. I already have defined for the project the secret what_a_secret for the key 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 .

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.

Your help would be warmly welcomed

EDIT: the documentation " Configure GitHub Actions " do not work to pass environment variables to a container.

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. But the docker read the secret correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM