Repository navigation
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·69 lines (59 loc) · 2.1 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·69 lines (59 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
platform=$(echo ${INPUT_FQBN} | sed 's|\(.*\):.*|\1|')
options=""
platform_version="${platform}"
if [[ ${platform} == "esp32:esp32" ]]
then
options="--additional-urls \"https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json\""
platform_version="${platform_version}@1.0.6"
fi
if [[ ${platform} == "esp8266:esp8266" ]]
then
options="--additional-urls \"https://arduino.esp8266.com/stable/package_esp8266com_index.json\""
platform_version="${platform_version}@2.7.4"
fi
echo "Update arduino cli core index"
arduino-cli core update-index ${options}
echo "Install arduino cli core and tool dependencies"
arduino-cli core install "${platform_version}" ${options}
echo "Install espcd-library dependency"
mkdir -p ~/Arduino/libraries
git clone https://github.com/espcd/espcd-library.git ~/Arduino/libraries/espcd-library
echo "Install AutoConnect dependency"
arduino-cli lib install AutoConnect
echo "Install ArduinoJson dependency"
arduino-cli lib install ArduinoJson
echo "Compile the arduino sketch"
arduino-cli compile --fqbn "${INPUT_FQBN}" --output-dir /tmp "${INPUT_SKETCH}"
echo "Upload compiled firmware to espcd-backend"
filename=$(basename "${INPUT_SKETCH}")
firmware_file="/tmp/${filename}.bin"
if [[ "${INPUT_COMPRESSION}" == "gzip" ]]
then
gzip -c "${firmware_file}" > "${firmware_file}".gz
firmware_file="${firmware_file}".gz
fi
response=$(
curl \
--silent \
--show-error \
--fail \
--request POST \
"${INPUT_URL}/firmwares?api_key=${INPUT_API_KEY}" \
-F "[firmware]title=${INPUT_TITLE}" \
-F "[firmware]description=${INPUT_DESCRIPTION}" \
-F "[firmware]version=${GITHUB_SHA}" \
-F "[firmware]fqbn=${INPUT_FQBN}" \
-F "[firmware]content=@${firmware_file}"
)
firmware_id=$(echo ${response} | jq ".id")
if [[ "${INPUT_PRODUCT}" ]]
then
curl \
--silent \
--show-error \
--fail \
--request PATCH \
"${INPUT_URL}/products/${INPUT_PRODUCT}/firmware/${INPUT_FQBN}?api_key=${INPUT_API_KEY}" \
-F "firmware_id=${firmware_id}"
fi