Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1074319f2 |
@@ -56,11 +56,10 @@ jobs:
|
||||
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true' || startsWith(github.ref, 'refs/tags/v')
|
||||
container:
|
||||
image: docker.io/espressif/idf:v5.3
|
||||
options: --network host
|
||||
steps:
|
||||
- name: Install tools
|
||||
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
|
||||
run: |
|
||||
@@ -73,37 +72,65 @@ jobs:
|
||||
cd get-started/csi_recv_router
|
||||
idf.py build
|
||||
|
||||
- name: Create release and upload firmware
|
||||
env:
|
||||
GITEA_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
REPO="${{ github.repository }}"
|
||||
API_URL="https://git.mymx.me/api/v1"
|
||||
|
||||
echo "Creating release for tag: $TAG"
|
||||
|
||||
# Check if release exists
|
||||
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
|
||||
|
||||
# Upload firmware binary
|
||||
echo "Uploading firmware..."
|
||||
curl -s -X POST -H "Authorization: token $GITEA_TOKEN" \
|
||||
-F "attachment=@get-started/csi_recv_router/build/csi_recv_router.bin" \
|
||||
"$API_URL/repos/$REPO/releases/$RELEASE_ID/assets?name=csi_recv_router.bin"
|
||||
|
||||
# Store release URL for OTA
|
||||
FIRMWARE_URL="https://git.mymx.me/$REPO/releases/download/$TAG/csi_recv_router.bin"
|
||||
echo "Firmware URL: $FIRMWARE_URL"
|
||||
echo "$FIRMWARE_URL" > /tmp/firmware_url.txt
|
||||
|
||||
- name: Deploy via OTA
|
||||
run: |
|
||||
PORT=8070
|
||||
|
||||
# Get host IP
|
||||
HOST_IP=$(hostname -I | awk '{print $1}')
|
||||
echo "Host IP: $HOST_IP"
|
||||
|
||||
# Start HTTP server in background
|
||||
cd get-started/csi_recv_router/build
|
||||
python3 -m http.server $PORT --bind 0.0.0.0 &
|
||||
HTTP_PID=$!
|
||||
sleep 2
|
||||
FIRMWARE_URL=$(cat /tmp/firmware_url.txt)
|
||||
echo "Using firmware URL: $FIRMWARE_URL"
|
||||
|
||||
# Deploy to muddy-storm
|
||||
echo "=== Deploying to muddy-storm (192.168.129.29) ==="
|
||||
echo "OTA http://${HOST_IP}:${PORT}/csi_recv_router.bin" | nc -u -w 2 192.168.129.29 5501 || true
|
||||
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 http://${HOST_IP}:${PORT}/csi_recv_router.bin" | nc -u -w 2 192.168.129.30 5501 || true
|
||||
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 http://${HOST_IP}:${PORT}/csi_recv_router.bin" | nc -u -w 2 192.168.129.31 5501 || true
|
||||
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 ==="
|
||||
|
||||
cppcheck:
|
||||
|
||||
Reference in New Issue
Block a user