From caed491f09ae32991b133b70fbb5076287086094 Mon Sep 17 00:00:00 2001 From: Nil <22560738+NilPuig@users.noreply.github.com> Date: Sun, 15 Feb 2026 14:13:50 +0800 Subject: [PATCH 1/2] Convert from Docker action to composite action The Docker-based action bundles its own Docker client (from the `docker:latest` image at build time). When GitHub updated their ubuntu-latest runners to require Docker API v1.44+, the action's bundled client (v1.40) became incompatible, breaking all users with: docker: Error response from daemon: client version 1.40 is too old. Minimum supported API version is 1.44 By switching to a composite action, the shell scripts run directly on the host runner using its native Docker client. This eliminates the Docker client version mismatch entirely and prevents this class of breakage from recurring. Changes: - action.yml: Switch from `using: docker` to `using: composite` - start-mongodb.sh: Read inputs from env vars instead of positional args - stop-mongodb.sh: Read inputs from env vars instead of positional args - Dockerfile is no longer used (composite actions run on the host) --- action.yml | 42 +++++++++++++++++++++++++----------------- start-mongodb.sh | 29 +++++++++++++++-------------- stop-mongodb.sh | 16 ++-------------- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/action.yml b/action.yml index bd0b05f..2faee74 100644 --- a/action.yml +++ b/action.yml @@ -72,20 +72,28 @@ inputs: default: '' runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.mongodb-image }} - - ${{ inputs.mongodb-version }} - - ${{ inputs.mongodb-replica-set }} - - ${{ inputs.mongodb-port }} - - ${{ inputs.mongodb-db }} - - ${{ inputs.mongodb-username }} - - ${{ inputs.mongodb-password }} - - ${{ inputs.mongodb-container-name }} - - ${{ inputs.mongodb-key }} - - ${{ inputs.mongodb-authsource }} - - ${{ inputs.mongodb-replica-set-host }} - - ${{ inputs.docker-network }} - - ${{ inputs.docker-network-alias }} - post-entrypoint: /stop-mongodb.sh + using: 'composite' + steps: + - name: Start MongoDB + shell: bash + env: + MONGODB_IMAGE: ${{ inputs.mongodb-image }} + MONGODB_VERSION: ${{ inputs.mongodb-version }} + MONGODB_REPLICA_SET: ${{ inputs.mongodb-replica-set }} + MONGODB_PORT: ${{ inputs.mongodb-port }} + MONGODB_DB: ${{ inputs.mongodb-db }} + MONGODB_USERNAME: ${{ inputs.mongodb-username }} + MONGODB_PASSWORD: ${{ inputs.mongodb-password }} + MONGODB_CONTAINER_NAME: ${{ inputs.mongodb-container-name }} + MONGODB_KEY: ${{ inputs.mongodb-key }} + MONGODB_AUTHSOURCE: ${{ inputs.mongodb-authsource }} + MONGODB_REPLICA_SET_HOST: ${{ inputs.mongodb-replica-set-host }} + DOCKER_NETWORK: ${{ inputs.docker-network }} + DOCKER_NETWORK_ALIAS: ${{ inputs.docker-network-alias }} + run: ${{ github.action_path }}/start-mongodb.sh + - name: Register MongoDB cleanup + if: always() + shell: bash + env: + MONGODB_CONTAINER_NAME: ${{ inputs.mongodb-container-name }} + run: ${{ github.action_path }}/stop-mongodb.sh diff --git a/start-mongodb.sh b/start-mongodb.sh index b34b56b..683d97d 100755 --- a/start-mongodb.sh +++ b/start-mongodb.sh @@ -1,19 +1,20 @@ #!/bin/sh -# Map input values from the GitHub Actions workflow to shell variables -MONGODB_IMAGE=$1 -MONGODB_VERSION=$2 -MONGODB_REPLICA_SET=$3 -MONGODB_PORT=$4 -MONGODB_DB=$5 -MONGODB_USERNAME=$6 -MONGODB_PASSWORD=$7 -MONGODB_CONTAINER_NAME=$8 -MONGODB_KEY=$9 -MONGODB_AUTHSOURCE=${10} -MONGODB_REPLICA_SET_HOST=${11:-"localhost"} -DOCKER_NETWORK=${12} -DOCKER_NETWORK_ALIAS=${13:-$MONGODB_CONTAINER_NAME} +# Variables are now passed via environment variables from action.yml +# Fall back to defaults matching action.yml inputs +MONGODB_IMAGE="${MONGODB_IMAGE:-mongo}" +MONGODB_VERSION="${MONGODB_VERSION:-latest}" +MONGODB_REPLICA_SET="${MONGODB_REPLICA_SET:-}" +MONGODB_PORT="${MONGODB_PORT:-27017}" +MONGODB_DB="${MONGODB_DB:-}" +MONGODB_USERNAME="${MONGODB_USERNAME:-}" +MONGODB_PASSWORD="${MONGODB_PASSWORD:-}" +MONGODB_CONTAINER_NAME="${MONGODB_CONTAINER_NAME:-mongodb}" +MONGODB_KEY="${MONGODB_KEY:-}" +MONGODB_AUTHSOURCE="${MONGODB_AUTHSOURCE:-admin}" +MONGODB_REPLICA_SET_HOST="${MONGODB_REPLICA_SET_HOST:-localhost}" +DOCKER_NETWORK="${DOCKER_NETWORK:-}" +DOCKER_NETWORK_ALIAS="${DOCKER_NETWORK_ALIAS:-$MONGODB_CONTAINER_NAME}" # If DOCKER_NETWORK not provided, try to detect the default GitHub Actions network if [ -z "$DOCKER_NETWORK" ]; then diff --git a/stop-mongodb.sh b/stop-mongodb.sh index ea2cf5d..c823b4f 100755 --- a/stop-mongodb.sh +++ b/stop-mongodb.sh @@ -1,19 +1,7 @@ #!/bin/sh -# Keep argument positions aligned with action.yml "args" so we can reuse them in post-args -MONGODB_IMAGE=$1 -MONGODB_VERSION=$2 -MONGODB_REPLICA_SET=$3 -MONGODB_PORT=$4 -MONGODB_DB=$5 -MONGODB_USERNAME=$6 -MONGODB_PASSWORD=$7 -MONGODB_CONTAINER_NAME=$8 -MONGODB_KEY=$9 -MONGODB_AUTHSOURCE=${10} -MONGODB_REPLICA_SET_HOST=${11:-"localhost"} -DOCKER_NETWORK=${12} -DOCKER_NETWORK_ALIAS=${13:-$MONGODB_CONTAINER_NAME} +# Variables are now passed via environment variables from action.yml +MONGODB_CONTAINER_NAME="${MONGODB_CONTAINER_NAME:-mongodb}" # Best-effort cleanup, do not fail the job if cleanup fails set +e From d9bd3d8f8a3b1ab72eaef7c0c9136e8bf613836b Mon Sep 17 00:00:00 2001 From: Nil <22560738+NilPuig@users.noreply.github.com> Date: Sun, 15 Feb 2026 14:24:24 +0800 Subject: [PATCH 2/2] Remove cleanup step that kills MongoDB before user tests run Composite actions don't support post-job hooks like Docker actions do. The 'Register MongoDB cleanup' step was running immediately after starting MongoDB, stopping the container before any subsequent workflow steps could use it. GitHub Actions runners are ephemeral, so the container is automatically cleaned up when the job ends. Users who need explicit cleanup can invoke stop-mongodb.sh in their own workflow steps. --- action.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/action.yml b/action.yml index 2faee74..9941624 100644 --- a/action.yml +++ b/action.yml @@ -91,9 +91,3 @@ runs: DOCKER_NETWORK: ${{ inputs.docker-network }} DOCKER_NETWORK_ALIAS: ${{ inputs.docker-network-alias }} run: ${{ github.action_path }}/start-mongodb.sh - - name: Register MongoDB cleanup - if: always() - shell: bash - env: - MONGODB_CONTAINER_NAME: ${{ inputs.mongodb-container-name }} - run: ${{ github.action_path }}/stop-mongodb.sh