diff --git a/.github/workflows/authentication.yml b/.github/workflows/authentication.yml new file mode 100644 index 0000000..1776734 --- /dev/null +++ b/.github/workflows/authentication.yml @@ -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 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 39c591f..c35c7a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index b3fdf84..00a1ecb 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/action.yml b/action.yml index 907777e..5778881 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 }} diff --git a/start-redis.sh b/start-redis.sh index fcafacc..3b3c737 100755 --- a/start-redis.sh +++ b/start-redis.sh @@ -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" @@ -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"