From b9fe748ee22d9b0127d366ca8cdc16d29edd2069 Mon Sep 17 00:00:00 2001 From: Yossi Farjoun Date: Sat, 3 Apr 2021 15:54:46 -0400 Subject: [PATCH 1/5] parent 358af5c6001dda30d591259839082c864e16a385 author Yossi Farjoun 1617479686 -0400 committer Yossi Farjoun 1618455120 -0400 Change the way the script is run. instead of modfying the ENTRYPOINT, we will simply add the "shell" (default sh) and the "script_prefix" (default -c) and then the script. That way the possible comple entry point is not disturbed. if a user would like to remove the ENTRYPOINT they can provide an "option" "--entrypoint ''" for example. --- .github/workflows/tests.yml | 2 +- README.md | 2 +- action.yml | 4 ++++ entrypoint.sh | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 66589bc..ff552af 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,7 +3,7 @@ name: Docker Run Action Tests on: push: branches: - - main + - '**' pull_request: jobs: diff --git a/README.md b/README.md index 8bdac31..15682c8 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,4 @@ run: | echo "first line" echo "second line" -``` + diff --git a/action.yml b/action.yml index 7c1a8e6..ed8cba2 100644 --- a/action.yml +++ b/action.yml @@ -15,6 +15,10 @@ inputs: description: 'Use a specific shell' required: false default: sh + script_prefix: + description: 'a prefix telling the shell to execute the following (single) string as a script' + required: false + default: -c registry: description: 'Registry' required: false diff --git a/entrypoint.sh b/entrypoint.sh index 39c1d70..020396a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,4 +8,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 -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX "${INPUT_RUN//$'\n'/;}" From ce038faf50e91f50fddd863d8fba33e43ea7a623 Mon Sep 17 00:00:00 2001 From: Yossi Farjoun Date: Mon, 15 Nov 2021 13:51:40 -0500 Subject: [PATCH 2/5] add the option to avoid the quotation of the input --- README.md | 2 +- action.yml | 6 +++++- entrypoint.sh | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 15682c8..8bdac31 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,4 @@ run: | echo "first line" echo "second line" - +``` diff --git a/action.yml b/action.yml index ed8cba2..a508c3b 100644 --- a/action.yml +++ b/action.yml @@ -16,9 +16,13 @@ inputs: required: false default: sh script_prefix: - description: 'a prefix telling the shell to execute the following (single) string as a script' + description: 'A prefix telling the shell to execute the following (single) string as a script' required: false default: -c + quote_argument: + description: 'Whether to quote the arguments when providing them to the docker as input' + required: false + default: true registry: description: 'Registry' required: false diff --git a/entrypoint.sh b/entrypoint.sh index 020396a..31b5f78 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,4 +8,7 @@ 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 $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX "${INPUT_RUN//$'\n'/;}" +if [ -z $INPUT_QUOTE_ARGUMENT ]; +then exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX "${INPUT_RUN//$'\n'/;}" +else exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX ${INPUT_RUN} +fi From 2dd654d9f4fe7239ef35ccec09fa808ad7e65f58 Mon Sep 17 00:00:00 2001 From: Yossi Farjoun Date: Mon, 15 Nov 2021 16:09:09 -0500 Subject: [PATCH 3/5] require true or false for quote_argument --- entrypoint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 31b5f78..3e59470 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,7 +8,10 @@ if [ ! -z $INPUT_DOCKER_NETWORK ]; then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK" fi -if [ -z $INPUT_QUOTE_ARGUMENT ]; +if [ $INPUT_QUOTE_ARGUMENT -eq "true" ]; then exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX "${INPUT_RUN//$'\n'/;}" -else exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX ${INPUT_RUN} +elif [ $INPUT_QUOTE_ARGUMENT -eq "false" ]; then exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX ${INPUT_RUN} +else + echo "Sorry, please specify 'true' or 'false' for the variable quote_argument" + exit 1 fi From 8192f7cdee474669b9efb0db5cdc05809eb0af96 Mon Sep 17 00:00:00 2001 From: Yossi Farjoun Date: Tue, 16 Nov 2021 15:00:39 -0500 Subject: [PATCH 4/5] == not -eq for strings --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 3e59470..dacf3a6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,9 +8,9 @@ if [ ! -z $INPUT_DOCKER_NETWORK ]; then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK" fi -if [ $INPUT_QUOTE_ARGUMENT -eq "true" ]; +if [ $INPUT_QUOTE_ARGUMENT == "true" ]; then exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX "${INPUT_RUN//$'\n'/;}" -elif [ $INPUT_QUOTE_ARGUMENT -eq "false" ]; then exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX ${INPUT_RUN} +elif [ $INPUT_QUOTE_ARGUMENT == "false" ]; then exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX ${INPUT_RUN} else echo "Sorry, please specify 'true' or 'false' for the variable quote_argument" exit 1 From 68ca7f9579d2aa6a2d138d843817f5140a4e6458 Mon Sep 17 00:00:00 2001 From: Yossi Farjoun Date: Tue, 16 Nov 2021 15:26:10 -0500 Subject: [PATCH 5/5] = not ==.... --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index dacf3a6..52ea7cd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,9 +8,9 @@ if [ ! -z $INPUT_DOCKER_NETWORK ]; then INPUT_OPTIONS="$INPUT_OPTIONS --network $INPUT_DOCKER_NETWORK" fi -if [ $INPUT_QUOTE_ARGUMENT == "true" ]; +if [ $INPUT_QUOTE_ARGUMENT = "true" ]; then exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX "${INPUT_RUN//$'\n'/;}" -elif [ $INPUT_QUOTE_ARGUMENT == "false" ]; then exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX ${INPUT_RUN} +elif [ $INPUT_QUOTE_ARGUMENT = "false" ]; then exec docker run -v "/var/run/docker.sock":"/var/run/docker.sock" $INPUT_OPTIONS $INPUT_IMAGE $INPUT_SHELL $INPUT_SCRIPT_PREFIX ${INPUT_RUN} else echo "Sorry, please specify 'true' or 'false' for the variable quote_argument" exit 1