diff --git a/README.md b/README.md index cb18c62..d79437e 100644 --- a/README.md +++ b/README.md @@ -48,4 +48,5 @@ steps: influxdb_user: ci_user influxdb_password: password influxdb_bucket: dummy -``` \ No newline at end of file + influxdb_token: apitoken +``` diff --git a/action.yml b/action.yml index 1388ff2..1e96053 100644 --- a/action.yml +++ b/action.yml @@ -10,7 +10,7 @@ inputs: influxdb_start: description: 'Set to false if you only need to use the cli tools without a locally running InfluxDB instance. If this is false, you can ignore the init parameters.' required: false - default: true + default: 'true' influxdb_org: description: 'The initial Organization of the InfluxDB instance.' required: false @@ -27,6 +27,9 @@ inputs: description: 'The initial Bucket of the InfluxDB instance.' required: false default: 'bucket' + influxdb_token: + description: 'The initial API Token of the InfluxDB instance.' + required: false runs: using: "composite" steps: @@ -42,6 +45,8 @@ runs: export INFLUXDB_USER=${{inputs.influxdb_user}} export INFLUXDB_PASSWORD=${{inputs.influxdb_password}} export INFLUXDB_BUCKET=${{inputs.influxdb_bucket}} + export INFLUXDB_TOKEN=${{inputs.influxdb_token}} ${{ github.action_path }}/setup-influxdb.sh unset INFLUXDB_PASSWORD + unset INFLUXDB_TOKEN shell: bash diff --git a/setup-influxdb.sh b/setup-influxdb.sh index 4e7c6f9..157cdc0 100755 --- a/setup-influxdb.sh +++ b/setup-influxdb.sh @@ -3,9 +3,17 @@ if [ "$INFLUXDB_START" = "true" ] then influxd --http-bind-address :8086 --reporting-disabled > /dev/null 2>&1 & until curl -s http://localhost:8086/health; do sleep 1; done - influx setup --host http://localhost:8086 -f \ - -o $INFLUXDB_ORG \ - -u $INFLUXDB_USER \ - -p $INFLUXDB_PASSWORD \ - -b $INFLUXDB_BUCKET + if [ -z ${INFLUXDB_TOKEN+x} ]; + then influx setup --host http://localhost:8086 -f \ + -o $INFLUXDB_ORG \ + -u $INFLUXDB_USER \ + -p $INFLUXDB_PASSWORD \ + -b $INFLUXDB_BUCKET + else influx setup --host http://localhost:8086 -f \ + -o $INFLUXDB_ORG \ + -u $INFLUXDB_USER \ + -p $INFLUXDB_PASSWORD \ + -b $INFLUXDB_BUCKET \ + -t $INFLUXDB_TOKEN + fi fi \ No newline at end of file