forked from supercharge/mongodb-github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop-mongodb.sh
More file actions
executable file
·32 lines (26 loc) · 866 Bytes
/
stop-mongodb.sh
File metadata and controls
executable file
·32 lines (26 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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}
# Best-effort cleanup, do not fail the job if cleanup fails
set +e
echo "::group::Cleaning up MongoDB container [$MONGODB_CONTAINER_NAME]"
if docker ps -a --format '{{.Names}}' | grep -Eq "^${MONGODB_CONTAINER_NAME}$"; then
docker rm -f "$MONGODB_CONTAINER_NAME" >/dev/null 2>&1 || true
echo "Removed container $MONGODB_CONTAINER_NAME"
else
echo "Container $MONGODB_CONTAINER_NAME not found; nothing to clean."
fi
echo "::endgroup::"
exit 0