diff --git a/.github/workflows/Build_Examples.yml b/.github/workflows/Build_Examples.yml index de4e32173ec..f5de5bfd84a 100644 --- a/.github/workflows/Build_Examples.yml +++ b/.github/workflows/Build_Examples.yml @@ -245,8 +245,10 @@ jobs: fi - name: Check watch files - id: check_watch + id: check_watch run: | + echo SOURCE_BRANCH = $SOURCE_BRANCH + echo TARGET_BRANCH = $TARGET_BRANCH # Determine if we need to run the test RUN_TEST=0 @@ -255,6 +257,11 @@ jobs: RUN_TEST=1 fi + if [[ $SOURCE_BRANCH == "main" ]]; then + echo "Pushed to main, running test" + RUN_TEST=1 + fi + # Check for changes made to these files WATCH_FILES="\ Build_Examples.yml \ @@ -268,8 +275,16 @@ jobs: makefile \ Makefile" - # Get the diff from main - CHANGE_FILES=$(git diff --ignore-submodules --name-only remotes/origin/main) + if [[ -n $TARGET_BRANCH ]]; then + # We are in a PR. Need to check changes against the target branch. + echo "Comparing PR against target branch: $TARGET_BRANCH" + echo "Adding remote '$GITHUB_SERVER_URL/$GITHUB_REPOSITORY' as 'upstream'" + git remote add upstream $GITHUB_SERVER_URL/$GITHUB_REPOSITORY + echo "Fetching $TARGET_BRANCH" + git fetch upstream $TARGET_BRANCH + echo "diffing files" + CHANGE_FILES=$(git diff --ignore-submodules --name-only remotes/upstream/$TARGET_BRANCH) + fi echo "Watching these locations and files" echo $WATCH_FILES