Compare commits

..

2 Commits

Author SHA1 Message Date
starcalc b96fe80792 Test pseudo-matrix-build
continuous-integration/drone/push Build is failing Details
2022-08-30 19:09:18 +02:00
starcalc 41685f46f3 Initial Hostsfile 2022-08-30 19:09:06 +02:00
2 changed files with 49 additions and 43 deletions

View File

@ -4,53 +4,57 @@ kind: pipeline
type: docker type: docker
name: default name: default
steps: steps:
- name: fetch ip - name: fetch ips
image: cburki/mosquitto-clients image: cburki/mosquitto-clients
commands: commands:
- echo "Hostname is ---${HOST}--- $HOST ... \$HOST ... \${HOST} +++ $\{HOST\}" - rm -f lastknownips
- mosquitto_sub -h raum.ctdo.de -t "homie/${HOST}/\$localip" -C 1 | tr -d '\n' - rm -f lastknownhostips
- mosquitto_sub -h raum.ctdo.de -t "homie/${HOST}/\$localip" -C 1 | tr -d '\n' >lastknownip - for h in $(cat hosts); do mosquitto_sub -h raum.ctdo.de -t \"homie/${h}/\$localip\" -C 1 | tr -d '\n' >>lastknownips
- cat "lastknownip" - for h in $(cat hosts); do echo "${h},$(mosquitto_sub -h raum.ctdo.de -t \"homie/${h}/\$localip\" -C 1 | tr -d '\n')" >>lastknownhostips
- name: configure # - mosquitto_sub -h raum.ctdo.de -t "homie/${HOST}/\$localip" -C 1 | tr -d '\n'
image: alpine # - mosquitto_sub -h raum.ctdo.de -t "homie/${HOST}/\$localip" -C 1 | tr -d '\n' >lastknownip
- cat lastknownips
- cat lastknownhostips
- name: build image
image: suculent/platformio-docker-build
commands: commands:
- sed -i "s/WIFISSID/$IOTSSID/" data/homie/config.json # Build image
- sed -i "s/WIFIPASS/$iotpwd/" data/homie/config.json - platformio run --environment d1_mini
- sed -i "s/HOSTNAME/${HOST}/g" data/homie/config.json - name: upload image
- sed -i "s/HOSTNAME/${HOST}/g" data/homie/config.json image: curlimages/curl
- lastknownip=$(cat lastknownip) commands:
- sed -i "s/HOSTNAME/$lastknownip/g" platformio.ini # 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: environment:
IOTSSID: IOTSSID:
from_secret: iotssid from_secret: iotssid
iotpwd: iotpwd:
from_secret: iotpwd from_secret: iotpwd
- name: build
image: suculent/platformio-docker-build
commands:
# - pip install -U platformio
# Build image
- platformio run --environment d1_mini
# Build file system image
- platformio run --target buildfs --environment d1_mini
- name: upload
image: curlimages/curl
commands:
- lastknownip=$(cat lastknownip)
- echo "$lastknownip"
# Upload image with espota-gateway
- |
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 firmware=@.pio/build/d1_mini/firmware.bin --no-buffer
# TODO: Upload file system image with espota-gateway, if the device is available again (or 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
### matrix-builds? - for multiple volumeknobs?
### https://0-8-0.docs.drone.io/matrix-builds/
###
matrix:
include:
HOST:
- blinky1
- blinky2

2
hosts Normal file
View File

@ -0,0 +1,2 @@
blinky1
blinky2