diff --git a/README.md b/README.md index e17f4a6..197bd65 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ jobs: node-version: ${{ matrix.node-version }} - name: Start Redis - uses: supercharge/redis-github-action@1.2.0 + uses: supercharge/redis-github-action@1.3.0 with: redis-version: ${{ matrix.redis-version }} @@ -68,6 +68,33 @@ jobs: ``` +### Using Redis on a Custom Port +You can start the Redis instance on a custom port using the `redis-port` input: + +```yaml +name: Run tests + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14.x, 16.x] + redis-version: [4, 5, 6] + + steps: + - name: Start Redis + uses: supercharge/redis-github-action@1.3.0 + with: + redis-version: ${{ matrix.redis-version }} + redis-port: 12345 + + - name: … +``` + + ## License MIT © [Supercharge](https://superchargejs.com) diff --git a/action.yml b/action.yml index e349371..d78491e 100644 --- a/action.yml +++ b/action.yml @@ -10,9 +10,13 @@ inputs: description: 'Redis version to use' required: false default: 'latest' - + redis-port: + description: 'Redis port to use and expose' + required: false + default: 6379 runs: using: 'docker' image: 'Dockerfile' args: - ${{ inputs.redis-version }} + - ${{ inputs.redis-port }} diff --git a/start-redis.sh b/start-redis.sh index 2897f67..cd9e385 100644 --- a/start-redis.sh +++ b/start-redis.sh @@ -1,6 +1,7 @@ #!/bin/sh REDIS_VERSION=$1 +REDIS_PORT=$2 if [ -z "$REDIS_VERSION" ]; then echo "Missing Redis version in the [redis-version] input. Received value: $REDIS_VERSION" @@ -9,4 +10,4 @@ if [ -z "$REDIS_VERSION" ]; then fi echo "Starting single-node Redis instance" -docker run --name redis --publish 6379:6379 --detach redis:$REDIS_VERSION +docker run --name redis --publish $REDIS_PORT:6379 --detach redis:$REDIS_VERSION