|
2 | 2 |
|
3 | 3 | # Get inputs from command |
4 | 4 | owner_repository=$1 |
5 | | -pr_number=$2 |
| 5 | +base_ref=$2 |
6 | 6 |
|
7 | | -url="https://api.github.com/repos/$owner_repository/pulls/$pr_number/files" |
8 | | -echo $url |
| 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 |
9 | 9 |
|
10 | | -# Get changes in boards.txt file from PR |
11 | | -Boards_modified_url=$(curl -s $url | jq -r '.[] | select(.filename == "boards.txt") | .raw_url') |
| 10 | +# Compare boards.txt file in the repo with the modified file from PR |
| 11 | +diff=$(diff -u boards_base.txt boards.txt) |
12 | 12 |
|
13 | | -# Echo the modified boards.txt file URL |
14 | | -echo "Modified boards.txt file URL:" |
15 | | -echo $Boards_modified_url |
16 | | - |
17 | | -# Download the modified boards.txt file |
18 | | -curl -L -o boards_pr.txt $Boards_modified_url |
19 | | - |
20 | | -# Check if the file is downloaded |
21 | | -if [ ! -f boards_pr.txt ] |
| 13 | +# Check if the diff is empty |
| 14 | +if [ -z "$diff" ] |
22 | 15 | then |
23 | | - echo "Error: boards.txt file not downloaded" |
24 | | - exit 1 |
| 16 | + echo "No changes in boards.txt file" |
| 17 | + echo "FQBNS=" |
| 18 | + exit 0 |
25 | 19 | fi |
26 | 20 |
|
27 | | -# Compare boards.txt file in the repo with the modified file |
28 | | -diff=$(diff -u boards.txt boards_pr.txt) |
29 | | - |
30 | 21 | # Extract added or modified lines (lines starting with '+' or '-') |
31 | 22 | modified_lines=$(echo "$diff" | grep -E '^[+-][^+-]') |
32 | 23 |
|
33 | | -# Print the modified lines |
| 24 | +# Print the modified lines for debugging |
34 | 25 | echo "Modified lines:" |
35 | 26 | echo "$modified_lines" |
36 | 27 |
|
37 | | - |
38 | 28 | boards_array=() |
39 | 29 | previous_board="" |
40 | 30 |
|
|
55 | 45 | fi |
56 | 46 | done <<< "$modified_lines" |
57 | 47 |
|
58 | | -# Print all boards found |
59 | | -echo "Boards found:" |
60 | | -for board in ${boards_array[@]} |
61 | | -do |
62 | | - echo $board |
63 | | -done |
64 | | - |
65 | | - |
66 | 48 | # Create JSON like string with all boards found and pass it to env variable |
67 | 49 | board_count=${#boards_array[@]} |
68 | 50 |
|
|
0 commit comments