Skip to content

Commit 01d81d2

Browse files
committed
support custom port
1 parent 25915a9 commit 01d81d2

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
node-version: ${{ matrix.node-version }}
5757

5858
- name: Start Redis
59-
uses: supercharge/redis-github-action@1.2.0
59+
uses: supercharge/redis-github-action@1.3.0
6060
with:
6161
redis-version: ${{ matrix.redis-version }}
6262

@@ -68,6 +68,33 @@ jobs:
6868
```
6969
7070
71+
### Using Redis on a Custom Port
72+
You can start the Redis instance on a custom port using the `redis-port` input:
73+
74+
```yaml
75+
name: Run tests
76+
77+
on: [push]
78+
79+
jobs:
80+
build:
81+
runs-on: ubuntu-latest
82+
strategy:
83+
matrix:
84+
node-version: [14.x, 16.x]
85+
redis-version: [4, 5, 6]
86+
87+
steps:
88+
- name: Start Redis
89+
uses: supercharge/redis-github-action@1.3.0
90+
with:
91+
redis-version: ${{ matrix.redis-version }}
92+
redis-port: 12345
93+
94+
- name: …
95+
```
96+
97+
7198
## License
7299
MIT © [Supercharge](https://superchargejs.com)
73100

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ inputs:
1010
description: 'Redis version to use'
1111
required: false
1212
default: 'latest'
13-
13+
redis-port:
14+
description: 'Redis port to use and expose'
15+
required: false
16+
default: 6379
1417
runs:
1518
using: 'docker'
1619
image: 'Dockerfile'
1720
args:
1821
- ${{ inputs.redis-version }}
22+
- ${{ inputs.redis-port }}

start-redis.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/sh
22

33
REDIS_VERSION=$1
4+
REDIS_PORT=$2
45

56
if [ -z "$REDIS_VERSION" ]; then
67
echo "Missing Redis version in the [redis-version] input. Received value: $REDIS_VERSION"
@@ -9,4 +10,4 @@ if [ -z "$REDIS_VERSION" ]; then
910
fi
1011

1112
echo "Starting single-node Redis instance"
12-
docker run --name redis --publish 6379:6379 --detach redis:$REDIS_VERSION
13+
docker run --name redis --publish $REDIS_PORT:6379 --detach redis:$REDIS_VERSION

0 commit comments

Comments
 (0)