File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1+ name : Start Redis server with remove container flag
2+
3+ on : [push, pull_request]
4+
5+ jobs :
6+ redis-action :
7+ runs-on : ubuntu-latest
8+ strategy :
9+ matrix :
10+ redis-version : [5, 6, 7]
11+
12+ name : Start Redis Server v${{ matrix.redis-version }}
13+ steps :
14+ - name : Checkout
15+ uses : actions/checkout@v4
16+
17+ - name : Start Redis Server
18+ uses : ./
19+ with :
20+ redis-version : ${{ matrix.redis-version }}
21+ redis-remove-container : true # false by default
Original file line number Diff line number Diff line change @@ -7,21 +7,28 @@ REDIS_PASSWORD=$4
77REDIS_CONTAINER_NAME=$5
88REDIS_REMOVE_CONTAINER=$6
99
10+ # 🛡️ Default version fallback
1011if [ -z " $REDIS_VERSION " ]; then
1112 echo " Missing Redis version in the [redis-version] input. Received value: $REDIS_VERSION "
1213 echo " Falling back to Redis version [latest]"
1314 REDIS_VERSION=' latest'
1415fi
1516
16- DOCKER_RUN_ARGS=" --name $REDIS_CONTAINER_NAME --publish $REDIS_PORT :6379 --detach $REDIS_IMAGE :$REDIS_VERSION "
17+ # 🛠️ Build docker run args
18+ DOCKER_RUN_ARGS=" --name $REDIS_CONTAINER_NAME --publish $REDIS_PORT :6379 --detach"
1719
18- if [ " $REDIS_REMOVE_CONTAINER " == " true" ]; then
19- DOCKER_RUN_ARGS=" $DOCKER_RUN_ARGS --rm"
20+ # 🗑️ If remove flag is true, run container with --rm (auto-remove on exit)
21+ if [ " $REDIS_REMOVE_CONTAINER " = " true" ]; then
22+ DOCKER_RUN_ARGS=" --rm $DOCKER_RUN_ARGS "
2023fi
2124
25+ # 🔐 Add password if provided
2226if [ -n " $REDIS_PASSWORD " ]; then
23- DOCKER_RUN_ARGS=" $DOCKER_RUN_ARGS redis-server --requirepass $REDIS_PASSWORD "
27+ DOCKER_RUN_ARGS=" $DOCKER_RUN_ARGS $REDIS_IMAGE :$REDIS_VERSION redis-server --requirepass $REDIS_PASSWORD "
28+ else
29+ DOCKER_RUN_ARGS=" $DOCKER_RUN_ARGS $REDIS_IMAGE :$REDIS_VERSION "
2430fi
2531
32+ # 🚀 Start Redis
2633echo " Starting single-node Redis instance: $DOCKER_RUN_ARGS "
2734docker run $DOCKER_RUN_ARGS
You can’t perform that action at this time.
0 commit comments