Skip to content

Commit a124277

Browse files
committed
fix(ci): Get correct file for the diff
1 parent 4285912 commit a124277

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

.github/scripts/find_new_boards.sh

+16-15
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@
22

33
# Get inputs from command
44
owner_repository=$1
5-
pr_number=$2
5+
base_ref=$2
66

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
99

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)
1212

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-
# Compare boards.txt file in the repo with the modified file
21-
diff=$(diff -u boards.txt boards_pr.txt)
13+
# Check if the diff is empty
14+
if [ -z "$diff" ]
15+
then
16+
echo "No changes in boards.txt file"
17+
echo "FQBNS="
18+
exit 0
19+
fi
2220

2321
# Extract added or modified lines (lines starting with '+' or '-')
2422
modified_lines=$(echo "$diff" | grep -E '^[+-][^+-]')
2523

24+
# Print the modified lines for debugging
25+
echo "Modified lines:"
26+
echo "$modified_lines"
27+
2628
boards_array=()
2729
previous_board=""
28-
file="boards.txt"
2930

3031
# Extract board names from the modified lines, and add them to the boards_array
3132
while read -r line

.github/workflows/boards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- name: Get board name
3131
run:
32-
bash .github/scripts/find_new_boards.sh ${{ github.repository }} ${{github.event.number}}
32+
bash .github/scripts/find_new_boards.sh ${{ github.repository }} ${{github.base_ref}}
3333

3434
test-boards:
3535
needs: find-boards

0 commit comments

Comments
 (0)