From 604e2b7e7b944f66d5e231c044729741623f8f37 Mon Sep 17 00:00:00 2001 From: neri Date: Sun, 27 Nov 2022 13:50:47 +0100 Subject: [PATCH] configure drone build --- .drone.yml | 46 ++++++++++++++++++++++++++++++++++++++++++ data/homie/config.json | 28 ++++++++++++------------- drone/espota-deploy.sh | 15 ++++++++++++++ platformio.ini | 2 +- 4 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 .drone.yml create mode 100755 drone/espota-deploy.sh diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..bcb002c --- /dev/null +++ b/.drone.yml @@ -0,0 +1,46 @@ +kind: pipeline +type: docker +name: default +steps: + - name: configure + image: alpine + commands: + - sed -i "s/HOSTNAME/$HOSTNAME/" data/homie/config.json + - sed -i "s/WIFI_SSID/$WIFI_SSID/" data/homie/config.json + - sed -i "s/WIFI_PASS/$WIFI_PASS/" data/homie/config.json + - cat data/homie/config.json + environment: + HOSTNAME: esp-waehlscheibe + WIFI_SSID: + from_secret: wifi_ssid + WIFI_PASS: + from_secret: wifi_pass + - name: build + image: infinitecoding/platformio-for-ci:latest + commands: + - platformio --version + # Build image + - platformio run --environment d1_mini + # Build file system image + - platformio run --target buildfs --environment d1_mini + - name: find device ip + image: cburki/mosquitto-clients + commands: + - mosquitto_sub -h mqtt.ctdo.de -t "homie/$HOSTNAME/\$localip" -C 1 | tr -d '\n' | tee device_ip + environment: + HOSTNAME: esp-waehlscheibe + when: + branch: + - master + - name: upload + image: curlimages/curl + commands: + - echo "$PWD" + - ls -al ./drone + # Upload firmware + - ./drone/espota-deploy.sh "$device_ip" ".pio/build/d1_mini/firmware.bin" + # Upload file system + - ./drone/espota-deploy.sh "$device_ip" ".pio/build/d1_mini/spiffs.bin" + when: + branch: + - master diff --git a/data/homie/config.json b/data/homie/config.json index 4654167..a5921e8 100644 --- a/data/homie/config.json +++ b/data/homie/config.json @@ -1,16 +1,16 @@ { -"name": "esp-waehlscheibe", -"device_id": "esp-waehlscheibe", -"wifi": { -"ssid": "CTDO-IoT", -"password": "12345678" -}, -"mqtt": { -"host": "mqtt.ctdo.de", -"port": 1883, -"auth": false -}, -"ota": { -"enabled": false -} + "name": "HOSTNAME", + "device_id": "HOSTNAME", + "wifi": { + "ssid": "WIFI_SSID", + "password": "WIFI_PASS" + }, + "mqtt": { + "host": "mqtt.ctdo.de", + "port": 1883, + "auth": false + }, + "ota": { + "enabled": false + } } diff --git a/drone/espota-deploy.sh b/drone/espota-deploy.sh new file mode 100755 index 0000000..7edb3df --- /dev/null +++ b/drone/espota-deploy.sh @@ -0,0 +1,15 @@ +#!/bin/env sh + +device_ip="$1" +file="$2" + +curl \ + --insecure \ + --no-progress-meter \ + --fail-with-body \ + --request POST \ + --url "https://espota.ctdo.de/" \ + --header "Content-Type: multipart/form-data" \ + --form ip="$device_ip" \ + --form "firmware=@$file" \ + --no-buffer diff --git a/platformio.ini b/platformio.ini index ab5712a..db357ca 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,5 +16,5 @@ upload_speed = 1500000 monitor_speed = 115200 lib_deps = bblanchon/ArduinoJson - me-no-dev/ESP Async WebServer@1.2.3 https://github.com/homieiot/homie-esp8266 + me-no-dev/ESP Async WebServer@1.2.3