From 80b3c0c0818c48908da591856eabe75d5e12ea12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Ju=C3=A1rez=20L=C3=B3pez?= Date: Mon, 9 Sep 2024 16:48:39 -0400 Subject: [PATCH] [ci] Fix bazel check for changes (#28) * Add tmp echo debug statements * Simulate changes in test * try * quick test * patch for now * undo --- ci/check_bazel.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ci/check_bazel.sh b/ci/check_bazel.sh index f11fc47..9036f37 100755 --- a/ci/check_bazel.sh +++ b/ci/check_bazel.sh @@ -11,11 +11,15 @@ set -euo pipefail # Trap to handle unexpected errors and log them trap 'echo "An unexpected error occurred during Bazel check."; echo "check_result=1" >> "$GITHUB_OUTPUT"; exit 1' ERR -# Ensure we fetch the base branch (main) to make it available -git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF" +# Check if GITHUB_BASE_REF is set (i.e., you're in a pull request) +if [ -n "$GITHUB_BASE_REF" ]; then + git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF" + base_sha=$(git rev-parse "$GITHUB_BASE_REF") +else + echo "Not in a pull request, skipping base ref fetch." + base_sha=$(git rev-parse HEAD) +fi -# Get the latest commit SHA for the base branch (target branch of the PR) -base_sha=$(git rev-parse "$GITHUB_BASE_REF") # Get the latest commit SHA for the PR branch (the head ref in the forked repository) final_revision=$GITHUB_SHA