Merge pull request #17 from newarifrh/main

feat: add redis auth
pull/19/head
Marcus Pöhls 2023-08-15 09:53:56 +02:00 committed by GitHub
commit 507b06bee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 3 deletions

21
.github/workflows/authentication.yml vendored Normal file
View File

@ -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

View File

@ -1,5 +1,12 @@
# Changelog # 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 ## [1.6.0](https://github.com/supercharge/redis-github-action/compare/v1.5.0...v1.6.0) - 2023-07-27

View File

@ -170,6 +170,30 @@ jobs:
- name: … - 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 ## License
MIT © [Supercharge](https://superchargejs.com) MIT © [Supercharge](https://superchargejs.com)

View File

@ -18,6 +18,10 @@ inputs:
description: 'Redis port to use and expose' description: 'Redis port to use and expose'
required: false required: false
default: 6379 default: 6379
redis-password:
description: "Redis password to use"
required: false
default: ''
redis-container-name: redis-container-name:
description: "Name of the created container. Useful if you run multiple Redis containers" description: "Name of the created container. Useful if you run multiple Redis containers"
required: false required: false
@ -35,5 +39,6 @@ runs:
- ${{ inputs.redis-image }} - ${{ inputs.redis-image }}
- ${{ inputs.redis-version }} - ${{ inputs.redis-version }}
- ${{ inputs.redis-port }} - ${{ inputs.redis-port }}
- ${{ inputs.redis-password }}
- ${{ inputs.redis-container-name }} - ${{ inputs.redis-container-name }}
- ${{ inputs.redis-remove-container }} - ${{ inputs.redis-remove-container }}

View File

@ -3,8 +3,9 @@
REDIS_IMAGE=$1 REDIS_IMAGE=$1
REDIS_VERSION=$2 REDIS_VERSION=$2
REDIS_PORT=$3 REDIS_PORT=$3
REDIS_CONTAINER_NAME=$4 REDIS_PASSWORD=$4
REDIS_REMOVE_CONTAINER=$5 REDIS_CONTAINER_NAME=$5
REDIS_REMOVE_CONTAINER=$6
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"
@ -14,8 +15,12 @@ fi
DOCKER_RUN_ARGS="--name $REDIS_CONTAINER_NAME --publish $REDIS_PORT:6379 --detach $REDIS_IMAGE:$REDIS_VERSION" 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 if [ "$REDIS_REMOVE_CONTAINER" == "true" ] ; then
DOCKER_RUN_ARGS+=" --rm" DOCKER_RUN_ARGS="$DOCKER_RUN_ARGS --rm"
fi fi
echo "Starting single-node Redis instance: $DOCKER_RUN_ARGS" echo "Starting single-node Redis instance: $DOCKER_RUN_ARGS"