diff --git a/.github/workflows/protect-file.yml b/.github/workflows/protect-file.yml index 645d6c0e9ea4..809a9f2a6096 100644 --- a/.github/workflows/protect-file.yml +++ b/.github/workflows/protect-file.yml @@ -28,11 +28,8 @@ jobs: echo "Starting file check step" base_ref=$(echo "${GITHUB_CONTEXT}" | jq -r ".base_ref") echo "Base branch reference extracted: ${base_ref}" - protected_file="src/sonic-config-engine/minigraph.py" - git fetch origin $base_ref # Fetch the base branch to ensure it's up-to-date - base_branch=$(git rev-parse origin/$base_ref) - echo "Base branch SHA: $base_branch" - echo "Running git diff check" + protected_file='src/sonic-config-engine/minigraph.py' + base_branch=$(git rev-parse origin/${base_ref}) if git diff --name-only $base_branch | grep -q "^${protected_file}\$"; then echo "Error: You are trying to modify ${protected_file}, which is protected." exit 1