From e30de98e6a9e6da13926dab80320c5e35f4dbb24 Mon Sep 17 00:00:00 2001 From: Ivan Schaller Date: Wed, 16 Aug 2023 12:10:20 +0200 Subject: [PATCH] make entrypoint optional --- .gitea/workflows/tests.yml | 5 +++-- action.yml | 5 ++--- entrypoint.sh | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml index 79f7c5a..1da473a 100644 --- a/.gitea/workflows/tests.yml +++ b/.gitea/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: image: debian:11-slim volumes: /tmp/:/tmp/ options: -e TESTENV=${{ gitea.workspace }} - run: echo "test" + run: env; echo "test" - name: multi-line options uses: https://git.44net.ch/actions/docker-run-action@main @@ -35,5 +35,6 @@ jobs: -e TESTENV=${{ gitea.workspace }} -e TESTENV2=TESTENV2 run: >- + env; sh -c - echo "test + echo "test" diff --git a/action.yml b/action.yml index e277bda..1cad315 100644 --- a/action.yml +++ b/action.yml @@ -28,10 +28,9 @@ inputs: description: "Command(s) to run in the container" required: false - shell: - description: "Shell to use" + entrypoint: + description: "Entrypoint for the container" required: false - default: sh registry: description: "Container registry URL" diff --git a/entrypoint.sh b/entrypoint.sh index 93f3ed4..7994188 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -28,6 +28,11 @@ if [ "${INPUT_MOUNT_SOCKET,,}" == "true" ]; then RUNTIME_OPTIONS+=(--volume "/var/run/docker.sock:/var/run/docker.sock") fi +# set entrypoint +if [ "${INPUT_ENTRYPOINT,,}" == "true" ]; then + RUNTIME_OPTIONS+=(--entrypoint="${INPUT_ENTRYPOINT}") +fi + # map volumes mapfile -t -d ' ' TMP_VOLUMES < <(printf -- '%s' "${INPUT_VOLUMES}") for vol in "${TMP_VOLUMES[@]}"; do @@ -49,7 +54,6 @@ done exec docker run \ --volume "${INPUT_WORKDIR}:${INPUT_WORKDIR}" \ --workdir "${INPUT_WORKDIR}" \ - --entrypoint="${INPUT_SHELL}" \ --env-file "/docker-run-action.env" \ "${RUNTIME_OPTIONS[@]}" \ "${CUSTOM_OPTIONS[@]}" \