File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1
1
FROM docker:stable
2
2
COPY start-mongodb.sh /start-mongodb.sh
3
- RUN chmod +x /start-mongodb.sh
3
+ COPY stop-mongodb.sh /stop-mongodb.sh
4
+ RUN chmod +x /start-mongodb.sh /stop-mongodb.sh
4
5
ENTRYPOINT ["/start-mongodb.sh" ]
Original file line number Diff line number Diff line change 70
70
- ${{ inputs.mongodb-container-name }}
71
71
- ${{ inputs.mongodb-key }}
72
72
- ${{ inputs.mongodb-authsource }}
73
+ post-entrypoint : /stop-mongodb.sh
74
+ post-args :
75
+ - ${{ inputs.mongodb-image }}
76
+ - ${{ inputs.mongodb-version }}
77
+ - ${{ inputs.mongodb-replica-set }}
78
+ - ${{ inputs.mongodb-port }}
79
+ - ${{ inputs.mongodb-db }}
80
+ - ${{ inputs.mongodb-username }}
81
+ - ${{ inputs.mongodb-password }}
82
+ - ${{ inputs.mongodb-container-name }}
83
+ - ${{ inputs.mongodb-key }}
84
+ - ${{ inputs.mongodb-authsource }}
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # Keep argument positions aligned with action.yml "args" so we can reuse them in post-args
4
+ MONGODB_IMAGE=$1
5
+ MONGODB_VERSION=$2
6
+ MONGODB_REPLICA_SET=$3
7
+ MONGODB_PORT=$4
8
+ MONGODB_DB=$5
9
+ MONGODB_USERNAME=$6
10
+ MONGODB_PASSWORD=$7
11
+ MONGODB_CONTAINER_NAME=$8
12
+ MONGODB_KEY=$9
13
+ MONGODB_AUTHSOURCE=${10}
14
+
15
+ # Best-effort cleanup, do not fail the job if cleanup fails
16
+ set +e
17
+
18
+ echo " ::group::Cleaning up MongoDB container [$MONGODB_CONTAINER_NAME ]"
19
+
20
+ if docker ps -a --format ' {{.Names}}' | grep -Eq " ^${MONGODB_CONTAINER_NAME} $" ; then
21
+ docker rm -f " $MONGODB_CONTAINER_NAME " > /dev/null 2>&1 || true
22
+ echo " Removed container $MONGODB_CONTAINER_NAME "
23
+ else
24
+ echo " Container $MONGODB_CONTAINER_NAME not found; nothing to clean."
25
+ fi
26
+
27
+ echo " ::endgroup::"
28
+
29
+ exit 0
You can’t perform that action at this time.
0 commit comments