Merge pull request #10 from YaraslauZhylko/feat/redis-image

feat: custom redis image
pull/15/head
Marcus Pöhls 2023-02-13 14:58:07 +01:00 committed by GitHub
commit 224466dd5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 7 deletions

21
.github/workflows/custom-image.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Start Redis server from a custom image
on: [push, pull_request]
jobs:
redis-action:
runs-on: ubuntu-latest
strategy:
matrix:
redis-version: [6.2.4-v4, 6.2.6-v3]
name: Start Redis Stack Server v${{ matrix.redis-version }}
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Start Redis Stack Server
uses: ./
with:
redis-image: redis/redis-stack-server
redis-version: ${{ matrix.redis-version }}

View File

@ -1,6 +1,12 @@
# Changelog
## [1.5.0](https://github.com/superchargejs/redis-github-action/compare/v1i.4.0...v1.5.0) - 2023-02-xx
### Added
- use a custom Redis image: useful if you need to run an alternative Redis image like Redis Stack
## [1.4.0](https://github.com/superchargejs/redis-github-action/compare/v1.3.0...v1.4.0) - 2021-12-28
### Added

View File

@ -56,7 +56,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
uses: supercharge/redis-github-action@1.5.0
with:
redis-version: ${{ matrix.redis-version }}
@ -68,6 +68,33 @@ jobs:
```
### Using a Custom Redis Image
You can utilize an alternative Redis image using the `redis-image` input:
```yaml
name: Run tests
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
redis-version: [6.2.4-v4, 6.2.6-v3]
steps:
- name: Start Redis
uses: supercharge/redis-github-action@1.5.0
with:
redis-image: redis/redis-stack-server
redis-version: ${{ matrix.redis-version }}
- name: …
```
### Using Redis on a Custom Port
You can start the Redis instance on a custom port using the `redis-port` input:
@ -86,7 +113,7 @@ jobs:
steps:
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
uses: supercharge/redis-github-action@1.5.0
with:
redis-version: ${{ matrix.redis-version }}
redis-port: 12345
@ -113,7 +140,7 @@ jobs:
steps:
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
uses: supercharge/redis-github-action@1.5.0
with:
redis-version: ${{ matrix.redis-version }}
redis-container-name: redis-auth-token-cache

View File

@ -6,6 +6,10 @@ branding:
color: 'red'
inputs:
redis-image:
description: 'Redis image to use. Useful if you need to run a custom Redis image'
required: false
default: 'redis'
redis-version:
description: 'Redis version to use'
required: false
@ -23,6 +27,7 @@ runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.redis-image }}
- ${{ inputs.redis-version }}
- ${{ inputs.redis-port }}
- ${{ inputs.redis-container-name }}

View File

@ -1,8 +1,9 @@
#!/bin/sh
REDIS_VERSION=$1
REDIS_PORT=$2
REDIS_CONTAINER_NAME=$3
REDIS_IMAGE=$1
REDIS_VERSION=$2
REDIS_PORT=$3
REDIS_CONTAINER_NAME=$4
if [ -z "$REDIS_VERSION" ]; then
echo "Missing Redis version in the [redis-version] input. Received value: $REDIS_VERSION"
@ -11,4 +12,4 @@ if [ -z "$REDIS_VERSION" ]; then
fi
echo "Starting single-node Redis instance"
docker run --name $REDIS_CONTAINER_NAME --publish $REDIS_PORT:6379 --detach redis:$REDIS_VERSION
docker run --name $REDIS_CONTAINER_NAME --publish $REDIS_PORT:6379 --detach $REDIS_IMAGE:$REDIS_VERSION