Blinky/.drone.yml

59 lines
2.7 KiB
YAML
Raw Normal View History

2022-08-30 15:50:09 +00:00
---
kind: pipeline
type: docker
name: default
steps:
2022-08-30 17:09:18 +00:00
- name: fetch ips
2022-08-30 15:50:09 +00:00
image: cburki/mosquitto-clients
commands:
2022-08-30 17:10:34 +00:00
- for h in $(cat hosts); do mosquitto_sub -h raum.ctdo.de -t \"homie/${h}/\$localip\" -C 1 | tr -d '\n'; done >lastknownips
- for h in $(cat hosts); do echo "${h},$(mosquitto_sub -h raum.ctdo.de -t \"homie/${h}/\$localip\" -C 1 | tr -d '\n')"; done >lastknownhostips
2022-08-30 17:09:18 +00:00
# - mosquitto_sub -h raum.ctdo.de -t "homie/${HOST}/\$localip" -C 1 | tr -d '\n'
# - mosquitto_sub -h raum.ctdo.de -t "homie/${HOST}/\$localip" -C 1 | tr -d '\n' >lastknownip
- cat lastknownips
- cat lastknownhostips
- name: build image
2022-08-30 15:50:09 +00:00
image: suculent/platformio-docker-build
commands:
# Build image
- platformio run --environment d1_mini
2022-08-30 17:09:18 +00:00
- name: upload image
2022-08-30 15:50:09 +00:00
image: curlimages/curl
commands:
# Upload image with espota-gateway
2022-08-30 17:09:18 +00:00
# All hosts receive the identical image
2022-08-30 15:50:09 +00:00
- |
2022-08-30 17:09:18 +00:00
for thisip in $(cat lastknownips)
do
echo ${thisip}
curl --insecure --no-progress-meter --fail-with-body --request POST --url "https://espota.ctdo.de/" --header "Content-Type: multipart/form-data" --form ip="$thisip" --form firmware=@.pio/build/d1_mini/firmware.bin --no-buffer
done
# Upload file system image with espota-gateway, leave it to espota-gateway to retry often enough
#- |
# curl --insecure --no-progress-meter --fail-with-body --request POST --url "https://espota.ctdo.de/" --header "Content-Type: multipart/form-data" --form ip="$lastknownip" --form spiffs=@.pio/build/d1_mini/spiffs.bin --no-buffer
- name: build configs
image: suculent/platformio-docker-build
commands:
2022-08-30 15:50:09 +00:00
- |
2022-08-30 17:09:18 +00:00
while IFS="," read -r curhost, curip
do
echo "Host ${curhost} and IP ${curip}"
cp data/homie/config.json data/homie/config.json.sample
sed -i "s/WIFISSID/$IOTSSID/" data/homie/config.json
sed -i "s/WIFIPASS/$iotpwd/" data/homie/config.json
sed -i "s/HOSTNAME/${curhost}/g" data/homie/config.json
sed -i "s/HOSTNAME/${curhost}/g" data/homie/config.json
# Build image with these parameters
platformio run --target buildfs --environment d1_mini
# Upload this image
curl --insecure --no-progress-meter --fail-with-body --request POST --url "https://espota.ctdo.de/" --header "Content-Type: multipart/form-data" --form ip="$curip" --form spiffs=@.pio/build/d1_mini/spiffs.bin --no-buffer
# Revert config.json
cp data/homie/config.json.sample data/homie/config.json
done < <(cat lastknownhostips)
environment:
IOTSSID:
from_secret: iotssid
iotpwd:
from_secret: iotpwd