Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/container-remove-flag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Start Redis server with remove container flag

on: [push, pull_request]

jobs:
redis-action:
runs-on: ubuntu-latest
strategy:
matrix:
redis-version: [5, 6, 7]

name: Start Redis Server v${{ matrix.redis-version }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Start Redis Server
uses: ./
with:
redis-version: ${{ matrix.redis-version }}
redis-remove-container: true # false by default
15 changes: 11 additions & 4 deletions start-redis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@ REDIS_PASSWORD=$4
REDIS_CONTAINER_NAME=$5
REDIS_REMOVE_CONTAINER=$6

# 🛡️ Default version fallback
if [ -z "$REDIS_VERSION" ]; then
echo "Missing Redis version in the [redis-version] input. Received value: $REDIS_VERSION"
echo "Falling back to Redis version [latest]"
REDIS_VERSION='latest'
fi

DOCKER_RUN_ARGS="--name $REDIS_CONTAINER_NAME --publish $REDIS_PORT:6379 --detach $REDIS_IMAGE:$REDIS_VERSION"
# 🛠️ Build docker run args
DOCKER_RUN_ARGS="--name $REDIS_CONTAINER_NAME --publish $REDIS_PORT:6379 --detach"

if [ "$REDIS_REMOVE_CONTAINER" == "true" ]; then
DOCKER_RUN_ARGS="$DOCKER_RUN_ARGS --rm"
# 🗑️ If remove flag is true, run container with --rm (auto-remove on exit)
if [ "$REDIS_REMOVE_CONTAINER" = "true" ]; then
DOCKER_RUN_ARGS="--rm $DOCKER_RUN_ARGS"
fi

# 🔐 Add password if provided
if [ -n "$REDIS_PASSWORD" ]; then
DOCKER_RUN_ARGS="$DOCKER_RUN_ARGS redis-server --requirepass $REDIS_PASSWORD"
DOCKER_RUN_ARGS="$DOCKER_RUN_ARGS $REDIS_IMAGE:$REDIS_VERSION redis-server --requirepass $REDIS_PASSWORD"
else
DOCKER_RUN_ARGS="$DOCKER_RUN_ARGS $REDIS_IMAGE:$REDIS_VERSION"
fi

# 🚀 Start Redis
echo "Starting single-node Redis instance: $DOCKER_RUN_ARGS"
docker run $DOCKER_RUN_ARGS