Skip to content

Commit 7992bfb

Browse files
committed
feat: add redis auth
1 parent ce7e9ab commit 7992bfb

File tree

5 files changed

+65
-3
lines changed

5 files changed

+65
-3
lines changed

.github/workflows/authentication.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Start Redis server with Authentication
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
redis-action:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
redis-version: [4, 5, 6]
11+
12+
name: Start Redis Server v${{ matrix.redis-version }}
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v1
16+
17+
- name: Start Redis Server
18+
uses: ./
19+
with:
20+
redis-version: ${{ matrix.redis-version }}
21+
redis-password: password

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [1.7.0](https://github.com/supercharge/redis-github-action/compare/v1.6.0...v1.7.0) - 2023-08-12
4+
5+
### Added
6+
- add `redis-password` for start Redis with Authentication
7+
8+
### Updated
9+
- update versions in README
310

411
## [1.6.0](https://github.com/supercharge/redis-github-action/compare/v1.5.0...v1.6.0) - 2023-07-27
512

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@ jobs:
170170
- name: …
171171
```
172172

173+
### Using Authentication
174+
Starting in v1.7.0, You can start the Redis with Authentication using the `redis-password` input:
175+
176+
```yaml
177+
name: Run tests
178+
179+
on: [push]
180+
181+
jobs:
182+
build:
183+
runs-on: ubuntu-latest
184+
strategy:
185+
matrix:
186+
redis-version: [6, 7]
187+
188+
steps:
189+
- name: Start Redis
190+
uses: supercharge/[email protected]
191+
with:
192+
redis-version: ${{ matrix.redis-version }}
193+
redis-password: 'password'
194+
195+
- name: …
196+
```
173197

174198
## License
175199
MIT © [Supercharge](https://superchargejs.com)

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ inputs:
1818
description: 'Redis port to use and expose'
1919
required: false
2020
default: 6379
21+
redis-password:
22+
description: "Redis password to use"
23+
required: false
24+
default: ''
2125
redis-container-name:
2226
description: "Name of the created container. Useful if you run multiple Redis containers"
2327
required: false
@@ -35,5 +39,6 @@ runs:
3539
- ${{ inputs.redis-image }}
3640
- ${{ inputs.redis-version }}
3741
- ${{ inputs.redis-port }}
42+
- ${{ inputs.redis-password }}
3843
- ${{ inputs.redis-container-name }}
3944
- ${{ inputs.redis-remove-container }}

start-redis.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
REDIS_IMAGE=$1
44
REDIS_VERSION=$2
55
REDIS_PORT=$3
6-
REDIS_CONTAINER_NAME=$4
7-
REDIS_REMOVE_CONTAINER=$5
6+
REDIS_PASSWORD=$4
7+
REDIS_CONTAINER_NAME=$5
8+
REDIS_REMOVE_CONTAINER=$6
89

910
if [ -z "$REDIS_VERSION" ]; then
1011
echo "Missing Redis version in the [redis-version] input. Received value: $REDIS_VERSION"
@@ -14,8 +15,12 @@ fi
1415

1516
DOCKER_RUN_ARGS="--name $REDIS_CONTAINER_NAME --publish $REDIS_PORT:6379 --detach $REDIS_IMAGE:$REDIS_VERSION"
1617

18+
if [ -n "$REDIS_PASSWORD" ] ; then
19+
DOCKER_RUN_ARGS="$DOCKER_RUN_ARGS redis-server --requirepass $REDIS_PASSWORD"
20+
fi
21+
1722
if [ "$REDIS_REMOVE_CONTAINER" == "true" ] ; then
18-
DOCKER_RUN_ARGS+=" --rm"
23+
DOCKER_RUN_ARGS="$DOCKER_RUN_ARGS --rm"
1924
fi
2025

2126
echo "Starting single-node Redis instance: $DOCKER_RUN_ARGS"

0 commit comments

Comments
 (0)