Blinky/.drone.yml

63 lines
2.9 KiB
YAML

---
kind: pipeline
type: docker
name: default
steps:
- name: fetch ips
image: cburki/mosquitto-clients
commands:
- #mosquitto_sub -h raum.ctdo.de -t "homie/blinky1/\$localip" -C 1
- rm -f lastknownhostips
- cat hosts
- for h in $(cat hosts); do echo $h; echo $h; done
- for h in $(cat hosts); do mosquitto_sub -h raum.ctdo.de -t "homie/$h/\$localip" -C 1; done >lastknownips
- for h in $(cat hosts); do echo -n "$h," >>lastknownhostips; mosquitto_sub -h raum.ctdo.de -t "homie/$h/\$localip" -C 1 >>lastknownhostips; done
# - 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 lastknownhostips
- cat lastknownips
- name: build
image: suculent/platformio-docker-build
commands:
# Build image
- platformio run --environment d1_mini
- name: upload image
image: curlimages/curl
commands:
# Upload image with espota-gateway
# All hosts receive the identical image
- |
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:
- |
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