2 Commits

Author SHA1 Message Date
user
a1074319f2 ci: Upload firmware to Gitea releases for OTA
All checks were successful
Lint & Build / C/C++ Static Analysis (push) Successful in 35s
Lint & Build / Security Flaw Analysis (push) Successful in 19s
Lint & Build / Secret Scanning (push) Successful in 5s
Lint & Build / Shell Script Analysis (push) Successful in 7s
Lint & Build / Build Firmware (push) Successful in 2m17s
Lint & Build / Deploy to ESP Fleet (push) Successful in 3m29s
2026-02-05 13:48:08 +01:00
user
9ece83bac0 ci: Simplify deploy script to pure POSIX sh
All checks were successful
Lint & Build / C/C++ Static Analysis (push) Successful in 35s
Lint & Build / Security Flaw Analysis (push) Successful in 18s
Lint & Build / Secret Scanning (push) Successful in 5s
Lint & Build / Shell Script Analysis (push) Successful in 7s
Lint & Build / Build Firmware (push) Successful in 2m17s
Lint & Build / Deploy to ESP Fleet (push) Successful in 3m28s
2026-02-05 13:28:28 +01:00

View File

@@ -56,11 +56,10 @@ jobs:
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true' || startsWith(github.ref, 'refs/tags/v') if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true' || startsWith(github.ref, 'refs/tags/v')
container: container:
image: docker.io/espressif/idf:v5.3 image: docker.io/espressif/idf:v5.3
options: --network host
steps: steps:
- name: Install tools - name: Install tools
run: | run: |
apt-get update && apt-get install -y --no-install-recommends netcat-openbsd avahi-utils apt-get update && apt-get install -y --no-install-recommends netcat-openbsd curl jq
- name: Checkout - name: Checkout
run: | run: |
@@ -73,44 +72,65 @@ jobs:
cd get-started/csi_recv_router cd get-started/csi_recv_router
idf.py build idf.py build
- name: Deploy via OTA - name: Create release and upload firmware
shell: bash env:
GITEA_TOKEN: ${{ github.token }}
run: | run: |
# Sensor IPs (update if DHCP changes) TAG="${{ github.ref_name }}"
SENSOR_NAMES="muddy-storm amber-maple hollow-acorn" REPO="${{ github.repository }}"
SENSOR_IPS="192.168.129.29 192.168.129.30 192.168.129.31" API_URL="https://git.mymx.me/api/v1"
PORT=8070
# Get host IP - try multiple methods echo "Creating release for tag: $TAG"
HOST_IP=$(ip route get 1 2>/dev/null | awk '{print $7; exit}')
if [ -z "$HOST_IP" ]; then # Check if release exists
HOST_IP=$(hostname -I | awk '{print $1}') RELEASE=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"$API_URL/repos/$REPO/releases/tags/$TAG")
RELEASE_ID=$(echo "$RELEASE" | jq -r '.id // empty')
if [ -z "$RELEASE_ID" ]; then
# Create new release
RELEASE=$(curl -s -X POST -H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"$TAG\", \"name\": \"$TAG\", \"body\": \"Automated release from CI\"}" \
"$API_URL/repos/$REPO/releases")
RELEASE_ID=$(echo "$RELEASE" | jq -r '.id')
echo "Created release ID: $RELEASE_ID"
else
echo "Release exists with ID: $RELEASE_ID"
fi fi
echo "Host IP: $HOST_IP"
# Start HTTP server in background # Upload firmware binary
cd get-started/csi_recv_router/build echo "Uploading firmware..."
python3 -m http.server $PORT --bind 0.0.0.0 & curl -s -X POST -H "Authorization: token $GITEA_TOKEN" \
HTTP_PID=$! -F "attachment=@get-started/csi_recv_router/build/csi_recv_router.bin" \
sleep 2 "$API_URL/repos/$REPO/releases/$RELEASE_ID/assets?name=csi_recv_router.bin"
# Deploy to each sensor # Store release URL for OTA
set -- $SENSOR_IPS FIRMWARE_URL="https://git.mymx.me/$REPO/releases/download/$TAG/csi_recv_router.bin"
for sensor in $SENSOR_NAMES; do echo "Firmware URL: $FIRMWARE_URL"
SENSOR_IP="$1" echo "$FIRMWARE_URL" > /tmp/firmware_url.txt
shift
echo "=== Deploying to $sensor ($SENSOR_IP) ==="
# Send OTA command via UDP - name: Deploy via OTA
echo "OTA http://${HOST_IP}:${PORT}/csi_recv_router.bin" | nc -u -w 2 $SENSOR_IP 5501 run: |
echo "OTA command sent to $sensor" FIRMWARE_URL=$(cat /tmp/firmware_url.txt)
echo "Using firmware URL: $FIRMWARE_URL"
# Wait for device to download and reboot # Deploy to muddy-storm
sleep 30 echo "=== Deploying to muddy-storm (192.168.129.29) ==="
done echo "OTA $FIRMWARE_URL" | nc -u -w 2 192.168.129.29 5501 || true
sleep 30
# Deploy to amber-maple
echo "=== Deploying to amber-maple (192.168.129.30) ==="
echo "OTA $FIRMWARE_URL" | nc -u -w 2 192.168.129.30 5501 || true
sleep 30
# Deploy to hollow-acorn
echo "=== Deploying to hollow-acorn (192.168.129.31) ==="
echo "OTA $FIRMWARE_URL" | nc -u -w 2 192.168.129.31 5501 || true
sleep 30
# Cleanup
kill $HTTP_PID 2>/dev/null || true
echo "=== Deployment complete ===" echo "=== Deployment complete ==="
cppcheck: cppcheck: