Skip to content

Commit

Permalink
Initial Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Thulasiraj Komminar committed Jan 16, 2025
1 parent 87aaab2 commit 4caaafb
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: PR
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
auto-assign:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: "Auto-assign issue"
uses: pozil/auto-assign-issue@v1
with:
repo-token: ${{ secrets.BOT_GITHUB_TOKEN }}
assignees: thulasirajkomminar
numOfAssignee: 1
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
pull_request:
branches:
- main

jobs:
default:
name: "InfluxDB3 Action CI"
runs-on: ubuntu-latest

steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Setup InfluxDB3
id: setup-influxdb3
uses: ./
with:
influxdb3_database: sensordata
influxdb3_create_token: true

- name: List databases
shell: bash
run: |
echo "Version:"
docker exec influxdb3 influxdb3 --version
echo "Databases:"
docker exec influxdb3 influxdb3 show databases
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# influxdb3-action
A GitHub action for installing and configuring InfluxDB 3 Core

This action installs and configures [InfluxDB3 core](https://docs.influxdata.com/influxdb3/core/).

# Usage

See [action.yaml](action.yaml)

## Setup and configure InfluxDB3

```yaml
steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Setup InfluxDB3
uses: komminarlabs/influxdb3-action@v0
with:
influxdb3_database: sensordata
influxdb3_create_token: true
```
34 changes: 34 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'InfluxDB 3 Core Action'
description: 'Install and configure InfluxDB 3 Core.'
author: 'Thulasiraj Komminar'

branding:
icon: 'database'
color: 'purple'

inputs:
influxdb3_database:
description: "The initial database of the InfluxDB3 instance."
required: false
default: "default"

influxdb3_create_token:
description: "Whether to create an auth token."
required: false
default: "false"

outputs:
influxdb3-auth-token:
description: 'The token for InfluxDB3 authentication'
value: ${{ steps.install-influxdb3.outputs.influxdb3-auth-token }}

runs:
using: "composite"
steps:
- name: Download and Install InfluxDB3
id: install-influxdb3
shell: bash
run: |
export INFLUXDB3_DATABASE=${{inputs.influxdb3_database}}
export INFLUXDB3_CREATE_TOKEN=${{inputs.influxdb3_create_token}}
${{ github.action_path }}/influxdb3-install.sh
32 changes: 32 additions & 0 deletions influxdb3-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh -e

# Download and run InfluxDB 3.0
echo "Downloading and running InfluxDB 3.0..."
docker pull quay.io/influxdb/influxdb3-core:latest
docker tag quay.io/influxdb/influxdb3-core:latest influxdb3-core
docker run -d --name influxdb3 -p 8181:8181 influxdb3-core serve --object-store memory --writer-id writer0 > /dev/null

# Wait for container to be healthy
for i in $(seq 1 30); do
if docker inspect influxdb3 --format='{{.State.Running}}' | grep -q 'true'; then
sleep 2
echo "InfluxDB 3.0 is up and running"
break
fi
sleep 1
done

# Create the database
echo "Creating database: $INFLUXDB3_DATABASE..."
docker exec influxdb3 influxdb3 create database $INFLUXDB3_DATABASE
echo "Database $INFLUXDB3_DATABASE created."

if [ "$INFLUXDB3_CREATE_TOKEN" = "true" ]
then
echo "Creating token..."
INFLUXDB3_TOKEN=$(docker exec influxdb3 influxdb3 create token | grep "Token:" | awk '{print $2}' | head -n 1)
echo "Token created successfully. This will grant you access to every HTTP endpoint or deny it otherwise."

# Export the token to GITHUB_OUTPUT
echo "influxdb3-auth-token=$(echo $INFLUXDB3_TOKEN)" >> $GITHUB_OUTPUT
fi

0 comments on commit 4caaafb

Please sign in to comment.