support custom port

pull/7/head
Marcus Pöhls 2021-12-27 06:41:35 +01:00
parent 25915a9018
commit 01d81d2a1c
3 changed files with 35 additions and 3 deletions

View File

@ -56,7 +56,7 @@ jobs:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: Start Redis - name: Start Redis
uses: supercharge/redis-github-action@1.2.0 uses: supercharge/redis-github-action@1.3.0
with: with:
redis-version: ${{ matrix.redis-version }} 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 ## License
MIT © [Supercharge](https://superchargejs.com) MIT © [Supercharge](https://superchargejs.com)

View File

@ -10,9 +10,13 @@ inputs:
description: 'Redis version to use' description: 'Redis version to use'
required: false required: false
default: 'latest' default: 'latest'
redis-port:
description: 'Redis port to use and expose'
required: false
default: 6379
runs: runs:
using: 'docker' using: 'docker'
image: 'Dockerfile' image: 'Dockerfile'
args: args:
- ${{ inputs.redis-version }} - ${{ inputs.redis-version }}
- ${{ inputs.redis-port }}

View File

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
REDIS_VERSION=$1 REDIS_VERSION=$1
REDIS_PORT=$2
if [ -z "$REDIS_VERSION" ]; then if [ -z "$REDIS_VERSION" ]; then
echo "Missing Redis version in the [redis-version] input. Received value: $REDIS_VERSION" echo "Missing Redis version in the [redis-version] input. Received value: $REDIS_VERSION"
@ -9,4 +10,4 @@ if [ -z "$REDIS_VERSION" ]; then
fi fi
echo "Starting single-node Redis instance" 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