@@ -5,14 +5,13 @@ owner_repository=$1
5
5
base_ref=$2
6
6
7
7
# Download the boards.txt file from the base branch
8
- curl -L -o boards_base.txt https://raw.githubusercontent.com/$owner_repository / $base_ref /boards.txt
8
+ curl -L -o boards_base.txt https://raw.githubusercontent.com/" $owner_repository " / " $base_ref " /boards.txt
9
9
10
10
# Compare boards.txt file in the repo with the modified file from PR
11
11
diff=$( diff -u boards_base.txt boards.txt)
12
12
13
13
# Check if the diff is empty
14
- if [ -z " $diff " ]
15
- then
14
+ if [ -z " $diff " ]; then
16
15
echo " No changes in boards.txt file"
17
16
echo " FQBNS="
18
17
exit 0
21
20
# Extract added or modified lines (lines starting with '+' or '-')
22
21
modified_lines=$( echo " $diff " | grep -E ' ^[+-][^+-]' )
23
22
24
- # Print the modified lines for debugging
23
+ # Print the modified lines for debugging
25
24
echo " Modified lines:"
26
25
echo " $modified_lines "
27
26
28
27
boards_array=()
29
28
previous_board=" "
30
29
31
30
# Extract board names from the modified lines, and add them to the boards_array
32
- while read -r line
33
- do
31
+ while read -r line; do
34
32
board_name=$( echo " $line " | cut -d ' .' -f1 | cut -d ' #' -f1)
35
33
# remove + or - from the board name at the beginning
36
- board_name=$( echo " $board_name " | sed ' s/^[+-]//' )
37
- if [ " $board_name " != " " ] && [ " $board_name " != " +" ] && [ " $board_name " != " -" ] && [ " $board_name " != " esp32_family" ]
38
- then
39
- if [ " $board_name " != " $previous_board " ]
40
- then
34
+ board_name=${board_name# [-+]}
35
+ if [ " $board_name " != " " ] && [ " $board_name " != " +" ] && [ " $board_name " != " -" ] && [ " $board_name " != " esp32_family" ]; then
36
+ if [ " $board_name " != " $previous_board " ]; then
41
37
boards_array+=(" espressif:esp32:$board_name " )
42
38
previous_board=" $board_name "
43
39
echo " Added 'espressif:esp32:$board_name ' to array"
@@ -48,22 +44,19 @@ done <<< "$modified_lines"
48
44
# Create JSON like string with all boards found and pass it to env variable
49
45
board_count=${# boards_array[@]}
50
46
51
- if [ $board_count -gt 0 ]
52
- then
47
+ if [ " $board_count " -gt 0 ]; then
53
48
json_matrix=' {"fqbn": ['
54
- for board in ${boards_array[@]}
55
- do
49
+ for board in " ${boards_array[@]} " ; do
56
50
json_matrix+=' "' $board ' "'
57
- if [ $board_count -gt 1 ]
58
- then
51
+ if [ " $board_count " -gt 1 ]; then
59
52
json_matrix+=" ,"
60
53
fi
61
- board_count=$(( $ board_count - 1 ))
54
+ board_count=$(( board_count - 1 ))
62
55
done
63
56
json_matrix+=' ]}'
64
57
65
- echo $json_matrix
66
- echo " FQBNS=${json_matrix} " >> $GITHUB_ENV
58
+ echo " $json_matrix "
59
+ echo " FQBNS=${json_matrix} " >> " $GITHUB_ENV "
67
60
else
68
- echo " FQBNS=" >> $GITHUB_ENV
69
- fi
61
+ echo " FQBNS=" >> " $GITHUB_ENV "
62
+ fi
0 commit comments