diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml index 9e8ea5d..d8eef8f 100644 --- a/.gitea/workflows/tests.yml +++ b/.gitea/workflows/tests.yml @@ -17,6 +17,7 @@ jobs: - name: single-line options uses: https://git.44net.ch/actions/docker-run-action@main with: + debug: true image: debian:11-slim volumes: /tmp/:/tmp/ options: -e TESTENV=${{ gitea.workspace }} @@ -25,6 +26,7 @@ jobs: - name: multi-line options uses: https://git.44net.ch/actions/docker-run-action@main with: + debug: true image: debian:11-slim volumes: >- /tmp/:/tmp/ diff --git a/action.yml b/action.yml index 53c7d75..e735790 100644 --- a/action.yml +++ b/action.yml @@ -47,8 +47,13 @@ inputs: docker_network: description: "Docker container network to use" - default: ${{ job.container.network }} required: false + default: ${{ job.container.network }} + + debug: + description: "Enable debugging" + required: false + default: "false" runs: using: "docker" diff --git a/entrypoint.sh b/entrypoint.sh index 4091673..97e292e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,11 @@ set -euo pipefail +# set debugging +if [ -n "${INPUT_DEBUG}" ]; then + set -x +fi + RUNTIME_OPTIONS=() CUSTOM_OPTIONS=() RUN_COMMAND=() @@ -10,7 +15,7 @@ env | grep -v -E "^(#|;| |PATH|SHLVL|HOSTNAME|DOCKER_*)" | awk '$1 ~ /^\w+=/' | # login to container registry if [ -n "${INPUT_USERNAME}" ]; then - printf '%s' "'${INPUT_PASSWORD}'" | docker login "${INPUT_REGISTRY}" -u "${INPUT_USERNAME}" --password-stdin + printf -- '%s' "'${INPUT_PASSWORD}'" | docker login "${INPUT_REGISTRY}" -u "${INPUT_USERNAME}" --password-stdin fi # set custom network @@ -24,19 +29,19 @@ if [ "${INPUT_MOUNT_SOCKET,,}" == "true" ]; then fi # map volumes -mapfile -t -d ' ' TMP_VOLUMES < <(printf '%s' "${INPUT_VOLUMES}") +mapfile -t -d ' ' TMP_VOLUMES < <(printf -- '%s' "${INPUT_VOLUMES}") for vol in "${TMP_VOLUMES[@]}"; do RUNTIME_OPTIONS+=(--volume "${vol}") done # get custom options -mapfile -t -d ' ' TMP_OPTIONS < <(printf '%s' "${INPUT_OPTIONS}") +mapfile -t -d ' ' TMP_OPTIONS < <(printf -- '%s' "${INPUT_OPTIONS}") for opt in "${TMP_OPTIONS[@]}"; do CUSTOM_OPTIONS+=("${opt}") done # get run command -mapfile -t -d ' ' TMP_RUN < <(printf '%s' "${INPUT_RUN}") +mapfile -t -d ' ' TMP_RUN < <(printf -- '%s' "${INPUT_RUN}") for cmd in "${TMP_RUN[@]}"; do RUN_COMMAND+=("${cmd}") done