Skip to content

Commit

Permalink
support custom port
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuspoehls committed Dec 27, 2021
1 parent 25915a9 commit 01d81d2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
3 changes: 2 additions & 1 deletion start-redis.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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

0 comments on commit 01d81d2

Please sign in to comment.