add debug and fix printf
Some checks failed
run tests / run-container (push) Failing after 5s

This commit is contained in:
Ivan Schaller 2023-08-16 11:56:27 +02:00
parent 6a9f799df0
commit 51996b4b33
Signed by: olofvndrhr
GPG key ID: 2A6BE07D99C8C205
3 changed files with 17 additions and 5 deletions

View file

@ -17,6 +17,7 @@ jobs:
- name: single-line options - name: single-line options
uses: https://git.44net.ch/actions/docker-run-action@main uses: https://git.44net.ch/actions/docker-run-action@main
with: with:
debug: true
image: debian:11-slim image: debian:11-slim
volumes: /tmp/:/tmp/ volumes: /tmp/:/tmp/
options: -e TESTENV=${{ gitea.workspace }} options: -e TESTENV=${{ gitea.workspace }}
@ -25,6 +26,7 @@ jobs:
- name: multi-line options - name: multi-line options
uses: https://git.44net.ch/actions/docker-run-action@main uses: https://git.44net.ch/actions/docker-run-action@main
with: with:
debug: true
image: debian:11-slim image: debian:11-slim
volumes: >- volumes: >-
/tmp/:/tmp/ /tmp/:/tmp/

View file

@ -47,8 +47,13 @@ inputs:
docker_network: docker_network:
description: "Docker container network to use" description: "Docker container network to use"
default: ${{ job.container.network }}
required: false required: false
default: ${{ job.container.network }}
debug:
description: "Enable debugging"
required: false
default: "false"
runs: runs:
using: "docker" using: "docker"

View file

@ -2,6 +2,11 @@
set -euo pipefail set -euo pipefail
# set debugging
if [ -n "${INPUT_DEBUG}" ]; then
set -x
fi
RUNTIME_OPTIONS=() RUNTIME_OPTIONS=()
CUSTOM_OPTIONS=() CUSTOM_OPTIONS=()
RUN_COMMAND=() RUN_COMMAND=()
@ -10,7 +15,7 @@ env | grep -v -E "^(#|;| |PATH|SHLVL|HOSTNAME|DOCKER_*)" | awk '$1 ~ /^\w+=/' |
# login to container registry # login to container registry
if [ -n "${INPUT_USERNAME}" ]; then 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 fi
# set custom network # set custom network
@ -24,19 +29,19 @@ if [ "${INPUT_MOUNT_SOCKET,,}" == "true" ]; then
fi fi
# map volumes # 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 for vol in "${TMP_VOLUMES[@]}"; do
RUNTIME_OPTIONS+=(--volume "${vol}") RUNTIME_OPTIONS+=(--volume "${vol}")
done done
# get custom options # 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 for opt in "${TMP_OPTIONS[@]}"; do
CUSTOM_OPTIONS+=("${opt}") CUSTOM_OPTIONS+=("${opt}")
done done
# get run command # 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 for cmd in "${TMP_RUN[@]}"; do
RUN_COMMAND+=("${cmd}") RUN_COMMAND+=("${cmd}")
done done