From 0f5219df0e3222d9188334187b6bd0f11b7e2316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 23 Oct 2024 09:24:36 +0200 Subject: [PATCH] fix(ci): Get correct file for the diff (#10507) --- .github/scripts/find_new_boards.sh | 31 +++++++++++++++--------------- .github/workflows/boards.yml | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/scripts/find_new_boards.sh b/.github/scripts/find_new_boards.sh index 083f1448e83..706676b4a4c 100755 --- a/.github/scripts/find_new_boards.sh +++ b/.github/scripts/find_new_boards.sh @@ -2,30 +2,31 @@ # Get inputs from command owner_repository=$1 -pr_number=$2 +base_ref=$2 -url="https://api.github.com/repos/$owner_repository/pulls/$pr_number/files" -echo $url +# Download the boards.txt file from the base branch +curl -L -o boards_base.txt https://raw.githubusercontent.com/$owner_repository/$base_ref/boards.txt -# Get changes in boards.txt file from PR -Boards_modified_url=$(curl -s $url | jq -r '.[] | select(.filename == "boards.txt") | .raw_url') +# Compare boards.txt file in the repo with the modified file from PR +diff=$(diff -u boards_base.txt boards.txt) -# Echo the modified boards.txt file URL -echo "Modified boards.txt file URL:" -echo $Boards_modified_url - -# Download the modified boards.txt file -curl -L -o boards_pr.txt $Boards_modified_url - -# Compare boards.txt file in the repo with the modified file -diff=$(diff -u boards.txt boards_pr.txt) +# Check if the diff is empty +if [ -z "$diff" ] +then + echo "No changes in boards.txt file" + echo "FQBNS=" + exit 0 +fi # Extract added or modified lines (lines starting with '+' or '-') modified_lines=$(echo "$diff" | grep -E '^[+-][^+-]') +# Print the modified lines for debugging +echo "Modified lines:" +echo "$modified_lines" + boards_array=() previous_board="" -file="boards.txt" # Extract board names from the modified lines, and add them to the boards_array while read -r line diff --git a/.github/workflows/boards.yml b/.github/workflows/boards.yml index 8d5868b083b..a14f57508c6 100644 --- a/.github/workflows/boards.yml +++ b/.github/workflows/boards.yml @@ -29,7 +29,7 @@ jobs: - name: Get board name run: - bash .github/scripts/find_new_boards.sh ${{ github.repository }} ${{github.event.number}} + bash .github/scripts/find_new_boards.sh ${{ github.repository }} ${{github.base_ref}} test-boards: needs: find-boards