Skip to content

Commit

Permalink
Merge pull request #10 from YaraslauZhylko/feat/redis-image
Browse files Browse the repository at this point in the history
feat: custom redis image
  • Loading branch information
marcuspoehls authored Feb 13, 2023
2 parents c169aa5 + fa0e17e commit 224466d
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 7 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/custom-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 30 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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:

Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +27,7 @@ runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.redis-image }}
- ${{ inputs.redis-version }}
- ${{ inputs.redis-port }}
- ${{ inputs.redis-container-name }}
9 changes: 5 additions & 4 deletions start-redis.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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

0 comments on commit 224466d

Please sign in to comment.