diff --git a/action-types.yml b/action-types.yml index e567ea3..6dde1a6 100644 --- a/action-types.yml +++ b/action-types.yml @@ -26,3 +26,5 @@ inputs: type: string docker-network-alias: type: string + mongodb-extra-env: + type: string diff --git a/action.yml b/action.yml index bd0b05f..3e15d84 100644 --- a/action.yml +++ b/action.yml @@ -71,6 +71,11 @@ inputs: required: false default: '' + mongodb-extra-env: + description: 'Extra environment variables to pass to the MongoDB container, one KEY=VALUE per line (e.g. "GLIBC_TUNABLES=glibc.pthread.rseq=1")' + required: false + default: '' + runs: using: 'docker' image: 'Dockerfile' @@ -88,4 +93,5 @@ runs: - ${{ inputs.mongodb-replica-set-host }} - ${{ inputs.docker-network }} - ${{ inputs.docker-network-alias }} + - ${{ inputs.mongodb-extra-env }} post-entrypoint: /stop-mongodb.sh diff --git a/start-mongodb.sh b/start-mongodb.sh index b34b56b..025103e 100755 --- a/start-mongodb.sh +++ b/start-mongodb.sh @@ -14,6 +14,7 @@ MONGODB_AUTHSOURCE=${10} MONGODB_REPLICA_SET_HOST=${11:-"localhost"} DOCKER_NETWORK=${12} DOCKER_NETWORK_ALIAS=${13:-$MONGODB_CONTAINER_NAME} +MONGODB_EXTRA_ENV=${14} # If DOCKER_NETWORK not provided, try to detect the default GitHub Actions network if [ -z "$DOCKER_NETWORK" ]; then @@ -26,6 +27,17 @@ if [ -n "$DOCKER_NETWORK" ]; then NETWORK_ARGS="--network $DOCKER_NETWORK --network-alias $DOCKER_NETWORK_ALIAS" fi +# Build extra -e flags from newline-separated KEY=VALUE pairs +EXTRA_ENV_ARGS="" +if [ -n "$MONGODB_EXTRA_ENV" ]; then + while IFS= read -r env_line; do + [ -z "$env_line" ] && continue + EXTRA_ENV_ARGS="$EXTRA_ENV_ARGS -e $env_line" + done <