From b676a622cec856fefb2ec6c78785be3df917b21b Mon Sep 17 00:00:00 2001 From: vishnudxb Date: Sun, 24 May 2020 13:03:24 -0400 Subject: [PATCH] redis cluster for github action --- LICENSE.md | 21 +++++++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++-- action.yml | 34 +++++++++++++++++++++++----------- entrypoint.sh | 8 ++++---- 4 files changed, 74 insertions(+), 17 deletions(-) create mode 100644 LICENSE.md mode change 100644 => 100755 entrypoint.sh diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..fd97343 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Zhulik + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index ef2ccab..e761026 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,26 @@ -# redis-cluster -Github action for running a redis cluster for your workflow +# Redis Cluster GitHub Action + +This [GitHub Action](https://github.com/features/actions) sets up Redis cluster with 3 master and 3 slave in a single container for your testing purpose. + +The image used is from https://github.com/vishnudxb/docker-redis-cluster + +# Usage + +See [action.yml](action.yml) + +Basic: +```yaml +steps: +- uses: vishnudxb/redis-cluster@1.0.0 + with: + master1-port: '5000' + master2-port: '5001' + master3-port: '5002' + slave1-port: '5003' + slave2-port: '5003' + slave3-port: '5004' +``` + +# License + +The scripts and documentation in this project are released under the [MIT License](LICENSE) diff --git a/action.yml b/action.yml index 782c830..52034f6 100644 --- a/action.yml +++ b/action.yml @@ -1,16 +1,28 @@ -# action.yml -name: 'Hello World' -description: 'Greet someone and record the time' +name: 'Redis Cluster with Master-Slave' +description: 'Setup Redis cluster with 3 master and 3 slave in a single container' +author: 'Vishnu Nair' +branding: + icon: 'database' + color: 'red' inputs: - who-to-greet: # id of input - description: 'Who to greet' + master1-port: + description: 'Port number for master1' + required: true + master2-port: + description: 'Port number for master2' + required: true + master3-port: + description: 'Port number for master3' + required: true + slave1-port: + description: 'Port number for slave1' + required: true + slave2-port: + description: 'Port number for slave2' + required: true + slave3-port: + description: 'Port number for slave3' required: true - default: 'World' -outputs: - time: # id of output - description: 'The time we greeted you' runs: using: 'docker' image: 'Dockerfile' - args: - - ${{ inputs.who-to-greet }} diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index 7636076..4bcd253 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,5 @@ -#!/bin/sh -l +#!/bin/sh -echo "Hello $1" -time=$(date) -echo "::set-output name=time::$time" +docker_run="docker run -d -p $INPUT_MASTER1_PORT:6379 -p $INPUT_MASTER2_PORT:6380 -p $INPUT_MASTER3_PORT:6381 -p $INPUT_SLAVE1_PORT:6382 -p $INPUT_SLAVE2_PORT:6383 -p $INPUT_SLAVE3_PORT:6384 --name redis-cluster vishnunair/docker-redis-cluster:latest" + +sh -c "$docker_run"