Skip to content

Commit

Permalink
Merge pull request #17 from newarifrh/main
Browse files Browse the repository at this point in the history
feat: add redis auth
  • Loading branch information
marcuspoehls authored Aug 15, 2023
2 parents ce7e9ab + 7992bfb commit 507b06b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/authentication.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Start Redis server with Authentication

on: [push, pull_request]

jobs:
redis-action:
runs-on: ubuntu-latest
strategy:
matrix:
redis-version: [4, 5, 6]

name: Start Redis Server v${{ matrix.redis-version }}
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Start Redis Server
uses: ./
with:
redis-version: ${{ matrix.redis-version }}
redis-password: password
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.7.0](https://github.com/supercharge/redis-github-action/compare/v1.6.0...v1.7.0) - 2023-08-12

### Added
- add `redis-password` for start Redis with Authentication

### Updated
- update versions in README

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

Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,30 @@ jobs:
- name: …
```

### Using Authentication
Starting in v1.7.0, You can start the Redis with Authentication using the `redis-password` input:

```yaml
name: Run tests
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
redis-version: [6, 7]
steps:
- name: Start Redis
uses: supercharge/redis-github-action@1.6.0
with:
redis-version: ${{ matrix.redis-version }}
redis-password: 'password'
- name: …
```

## License
MIT © [Supercharge](https://superchargejs.com)
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
description: 'Redis port to use and expose'
required: false
default: 6379
redis-password:
description: "Redis password to use"
required: false
default: ''
redis-container-name:
description: "Name of the created container. Useful if you run multiple Redis containers"
required: false
Expand All @@ -35,5 +39,6 @@ runs:
- ${{ inputs.redis-image }}
- ${{ inputs.redis-version }}
- ${{ inputs.redis-port }}
- ${{ inputs.redis-password }}
- ${{ inputs.redis-container-name }}
- ${{ inputs.redis-remove-container }}
11 changes: 8 additions & 3 deletions start-redis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
REDIS_IMAGE=$1
REDIS_VERSION=$2
REDIS_PORT=$3
REDIS_CONTAINER_NAME=$4
REDIS_REMOVE_CONTAINER=$5
REDIS_PASSWORD=$4
REDIS_CONTAINER_NAME=$5
REDIS_REMOVE_CONTAINER=$6

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

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

if [ -n "$REDIS_PASSWORD" ] ; then
DOCKER_RUN_ARGS="$DOCKER_RUN_ARGS redis-server --requirepass $REDIS_PASSWORD"
fi

if [ "$REDIS_REMOVE_CONTAINER" == "true" ] ; then
DOCKER_RUN_ARGS+=" --rm"
DOCKER_RUN_ARGS="$DOCKER_RUN_ARGS --rm"
fi

echo "Starting single-node Redis instance: $DOCKER_RUN_ARGS"
Expand Down

0 comments on commit 507b06b

Please sign in to comment.