Skip to content

Commit 1285b7d

Browse files
committed
fix(examples): Replace env-vars in some sdkconfigs
1 parent 2541ba6 commit 1285b7d

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

.github/workflows/examples_build-host-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@ jobs:
5757
- name: Checkout esp-protocols
5858
uses: actions/checkout@v4
5959
- name: Build with IDF-${{ matrix.idf_ver }}
60+
env:
61+
MQTT_BROKER_URI: ${{ secrets.MQTT_BROKER_URI }}
6062
shell: bash
6163
run: |
6264
. ${IDF_PATH}/export.sh
65+
cat examples/mqtt/sdkconfig.defaults.linux
66+
echo "MQTT_BROKER_URI=${MQTT_BROKER_URI}"
67+
./ci/replace.sh examples/mqtt/sdkconfig.defaults.linux
68+
cat examples/mqtt/sdkconfig.defaults.linux
6369
python -m pip install idf-build-apps
6470
python ./ci/build_apps.py examples/mqtt -l -t linux
6571
timeout 25 ./examples/mqtt/build_linux_default/esp_mqtt_demo.elf | tee test.log || true

ci/replace.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [ -z "${IDF_PATH:-}" ]; then
6+
echo "Error: IDF_PATH is not set" >&2
7+
exit 1
8+
fi
9+
10+
ENVSUBST="$IDF_PATH/tools/ci/envsubst.py"
11+
12+
if [ ! -x "$ENVSUBST" ]; then
13+
echo "Error: envsubst.py not found or not executable at $ENVSUBST" >&2
14+
exit 1
15+
fi
16+
17+
for file in "$@"; do
18+
if [ ! -f "$file" ]; then
19+
echo "Warning: $file does not exist, skipping" >&2
20+
continue
21+
fi
22+
23+
# Create a temporary file to hold the output
24+
tmpfile=$(mktemp)
25+
26+
# Process the file
27+
cat "$file" | "$ENVSUBST" > "$tmpfile"
28+
29+
# Overwrite the original file with the processed content
30+
mv "$tmpfile" "$file"
31+
32+
echo "Processed: $file"
33+
done
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
CONFIG_IDF_TARGET="linux"
22
# CONFIG_ESP_EVENT_POST_FROM_ISR is not set
3+
CONFIG_BROKER_URL="mqtt://${MQTT_BROKER_URI}"

0 commit comments

Comments
 (0)