From 0e2542d6e668642b6ef5d4d02db092e911567262 Mon Sep 17 00:00:00 2001 From: Linas Daneliukas Date: Fri, 9 Jul 2021 10:47:15 +0300 Subject: [PATCH 1/4] Forward ENV to the sub-container --- entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 39c1d70..f771b0f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +env > docker-run-action.env +INPUT_OPTIONS="$INPUT_OPTIONS --env-file ./docker-run-action.env" + if [ ! -z $INPUT_USERNAME ]; then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin fi From 4835be1ddc17406cf733ce6a3ce0843f394619c6 Mon Sep 17 00:00:00 2001 From: Linas Daneliukas Date: Fri, 9 Jul 2021 11:30:50 +0300 Subject: [PATCH 2/4] Update example with env in step --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eab5a93..a56f2cf 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,14 @@ - name: Checkout uses: actions/checkout@v2 # Required to mount the Github Workspace to a volume - uses: addnab/docker-run-action@v3 + env: + ABC: 123 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} registry: gcr.io image: private-image:latest - options: -v ${{ github.workspace }}:/work -e ABC=123 + options: -v ${{ github.workspace }}:/work run: | echo "Running Script" /work/run-script From ef9d6a4beca82464251206f32fdb779314e6c983 Mon Sep 17 00:00:00 2001 From: Linas Daneliukas Date: Fri, 9 Jul 2021 15:05:33 +0300 Subject: [PATCH 3/4] Fix for multiline env vars in INPUT_RUN --- entrypoint.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f771b0f..06a7ef2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -env > docker-run-action.env -INPUT_OPTIONS="$INPUT_OPTIONS --env-file ./docker-run-action.env" +env | grep -v '^#' | xargs > docker-run-action.env if [ ! -z $INPUT_USERNAME ]; then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin @@ -11,4 +10,4 @@ if [ ! -z $INPUT_DOCKER_NETWORK ]; then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK" fi -exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "${INPUT_RUN//$'\n'/;}" +exec docker run --env-file docker-run-action.env -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS --entrypoint=$INPUT_SHELL $INPUT_IMAGE -c "${INPUT_RUN//$'\n'/;}" From 09a702b342aada2ca4b066053742b0a7d0f5d2e5 Mon Sep 17 00:00:00 2001 From: Linas Daneliukas Date: Fri, 14 Jan 2022 13:29:41 +0200 Subject: [PATCH 4/4] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 06a7ef2..cc8e887 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -env | grep -v '^#' | xargs > docker-run-action.env +env | egrep -v "^(#|;| |INPUT_*|PATH|HOME)" | awk '$1 ~ /^\w+=/' | xargs -0 > docker-run-action.env if [ ! -z $INPUT_USERNAME ]; then echo $INPUT_PASSWORD | docker login $INPUT_REGISTRY -u $INPUT_USERNAME --password-stdin