From b5b790e84fa8faac1707d65bbcd5a5a5e9e38322 Mon Sep 17 00:00:00 2001 From: Raymond Tukpe Date: Tue, 16 Aug 2022 15:04:08 +0100 Subject: [PATCH] initial commit --- .github/workflows/container-name.yml | 21 ++++++++++++ .github/workflows/custom-port.yml | 21 ++++++++++++ .../workflows/fallback-to-latest-version.yml | 17 ++++++++++ .github/workflows/main.yml | 20 +++++++++++ Dockerfile | 4 +++ action.yml | 33 +++++++++++++++++++ start-typesense.sh | 23 +++++++++++++ 7 files changed, 139 insertions(+) create mode 100644 .github/workflows/container-name.yml create mode 100644 .github/workflows/custom-port.yml create mode 100644 .github/workflows/fallback-to-latest-version.yml create mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile create mode 100644 action.yml create mode 100644 start-typesense.sh diff --git a/.github/workflows/container-name.yml b/.github/workflows/container-name.yml new file mode 100644 index 0000000..2030d97 --- /dev/null +++ b/.github/workflows/container-name.yml @@ -0,0 +1,21 @@ +name: Start Typesense server with custom container name + +on: [push, pull_request] + +jobs: + typesense-action: + runs-on: ubuntu-latest + strategy: + matrix: + typesense-version: [0.23.1] + + name: Start Typesense Server v${{ matrix.typesense-version }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Start Typesense Server + uses: ./ + with: + typesense-version: ${{ matrix.typesense-version }} + typesense-container-name: typesense-auth-token-cache diff --git a/.github/workflows/custom-port.yml b/.github/workflows/custom-port.yml new file mode 100644 index 0000000..73609b0 --- /dev/null +++ b/.github/workflows/custom-port.yml @@ -0,0 +1,21 @@ +name: Start typesense server on custom port + +on: [push, pull_request] + +jobs: + typesense-action: + runs-on: ubuntu-latest + strategy: + matrix: + typesense-version: [0.23.1] + + name: Start typesense Server v${{ matrix.typesense-version }} + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Start typesense Server + uses: ./ + with: + typesense-version: ${{ matrix.typesense-version }} + typesense-port: 12345 diff --git a/.github/workflows/fallback-to-latest-version.yml b/.github/workflows/fallback-to-latest-version.yml new file mode 100644 index 0000000..361751f --- /dev/null +++ b/.github/workflows/fallback-to-latest-version.yml @@ -0,0 +1,17 @@ +name: Start Typesense server with latest version + +on: [push, pull_request] + +jobs: + typesense-action: + runs-on: ubuntu-latest + + name: Start Typesense Server with latest Typesense version + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Start Typesense Server + uses: ./ + with: + typesense-version: ${{ matrix.typesense-versions }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..3e8943f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,20 @@ +name: Start Typesense server + +on: [push, pull_request] + +jobs: + typesense-action: + runs-on: ubuntu-latest + strategy: + matrix: + typesense-version: [0.23.1] + + name: Start Typesense Server v${{ matrix.typesense-version }} + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Start Typesense Server + uses: ./ + with: + typesense-version: ${{ matrix.typesense-version }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c4bc12d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM docker:stable +COPY start-typesense.sh /start-typesense.sh +RUN chmod +x /start-typesense.sh +ENTRYPOINT ["/start-typesense.sh"] \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..78c2d8d --- /dev/null +++ b/action.yml @@ -0,0 +1,33 @@ +name: "Typesense Server in GitHub Actions" +description: "Start a Typesense server" + +branding: + icon: "search" + color: "red" + +inputs: + typesense-version: + description: "typesense version to use" + required: false + default: "0.23.1" + typesense-port: + description: "typesense port to use and expose" + required: false + default: 8108 + typesense-container-name: + description: "Name of the created container. Useful if you run multiple typesense containers" + required: false + default: "typesense" + typesense-api-key: + description: "typesense api key" + required: false + default: "typesense" + +runs: + using: "docker" + image: "Dockerfile" + args: + - ${{ inputs.typesense-version }} + - ${{ inputs.typesense-port }} + - ${{ inputs.typesense-container-name }} + - ${{ inputs.typesense-api-key }} diff --git a/start-typesense.sh b/start-typesense.sh new file mode 100644 index 0000000..3a1a247 --- /dev/null +++ b/start-typesense.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +TYPESENSE_VERSION=$1 +TYPESENSE_PORT=$2 +TYPESENSE_CONTAINER_NAME=$3 +TYPESENSE_API_KEY=$4 + +if [ -z "$TYPESENSE_VERSION" ]; then + echo "Missing Typesense version in the [typesense-version] input. Received value: $TYPESENSE_VERSION" + echo "Falling back to Typesense version [0.23.1]" + TYPESENSE_VERSION='0.23.1' +fi + +echo "Starting single-node Typesense instance" +# mkdir /tmp/typesense-data +docker run -d \ + -p $TYPESENSE_PORT:8108 \ + # -v/tmp/typesense-data:/data \ + --name $TYPESENSE_CONTAINER_NAME \ + typesense/typesense:$TYPESENSE_VERSION \ + # --data-dir /data \ + --api-key=$TYPESENSE_API_KEY \ + --enable-cors \ No newline at end of file