Go to file
Gorlik e8219ffca8
Typo fix in changelog.md
2023-08-02 23:30:37 +02:00
.github/workflows feat: custom redis image 2023-02-13 01:26:11 +03:00
CHANGELOG.md Typo fix in changelog.md 2023-08-02 23:30:37 +02:00
Dockerfile no new line 2019-12-18 10:54:17 +01:00
LICENSE Initial commit 2019-12-17 13:26:53 +01:00
README.md update versions 2023-07-27 10:41:22 +02:00
action.yml Add option to remove container when it exits 2023-07-25 15:36:40 -07:00
start-redis.sh Add option to remove container when it exits 2023-07-25 15:36:40 -07:00

README.md



Redis in GitHub Actions

Start a Redis server in your GitHub Actions.


Usage



Follow @marcuspoehls and @superchargejs for updates!


Introduction

This GitHub Action starts a Redis server on the default port 6379.

This is useful when running tests against a Redis database.

Usage

A code example says more than a 1000 words. Heres an exemplary GitHub Action using a Redis server in versions 4 and 5 to test a Node.js app:

name: Run tests

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [18.x, 20.x]
        redis-version: [6, 7]

    steps:
    - name: Git checkout
      uses: actions/checkout@v2

    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}

    - name: Start Redis
      uses: supercharge/redis-github-action@1.6.0
      with:
        redis-version: ${{ matrix.redis-version }}

    - run: npm install

    - run: npm test
      env:
        CI: true

Using a Custom Redis Image

You can utilize an alternative Redis image using the redis-image input:

name: Run tests

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        redis-version: [6.2.4-v4, 6.2.6-v3]

    steps:
    - name: Start Redis
      uses: supercharge/redis-github-action@1.6.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:

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-port: 12345

    - name: 

Using a Custom Container Name

This GitHub Action provides a Redis Docker container. The default container name is redis. It can be helpful to customize the container name. For example, when running multiple Redis instances in parallel. You can customize the container name using the redis-container-name input:

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-container-name: redis-auth-token-cache

    - name: 

Remove container when exit

Starting in v1.6.0, when running this action on a self-hosted runner, its helpful to remove the container so its name wont conflict:

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-remove-container: true # false by default

    - name: 

License

MIT © Supercharge


superchargejs.com  ·  GitHub @supercharge  ·  Twitter @superchargejs