Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wen587 committed Jul 11, 2024
1 parent ea077ab commit 3278880
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/protect-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
base_ref=$(echo $GITHUB_CONTEXT | jq -r ".base_ref")
echo "base_ref ${base_ref}"
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"
base_branch=$(git rev-parse origin/${base_ref})
echo "base_br ${base_branch}"
if git diff --name-only $base_branch | grep -q "^$protected_file\$"; then
echo "Error: You are trying to modify $protected_file, which is protected."
echo "Base branch SHA: ${base_branch}"
echo "Running git diff check"
git fetch origin ${base_ref} # Fetch the base branch to ensure it's up-to-date
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
else
echo "No changes detected in ${protected_file}"
fi

0 comments on commit 3278880

Please sign in to comment.