@@ -12,7 +12,15 @@ cd "$(dirname "$0")/../.."
1212
1313# Configuration
1414DOCKER_IMAGE=" ${OASDIFF_DOCKER_IMAGE:- tufin/ oasdiff: latest} "
15- BASE_BRANCH=" ${BASE_BRANCH:- origin/ master} "
15+
16+ # Detect base branch from GitHub Actions environment or fallback to local defaults
17+ if [ -n " $GITHUB_BASE_REF " ]; then
18+ # In GitHub Actions PR, use the base ref (e.g., "master")
19+ BASE_BRANCH=" ${BASE_BRANCH:- origin/ $GITHUB_BASE_REF } "
20+ else
21+ # Local development: default to origin/master
22+ BASE_BRANCH=" ${BASE_BRANCH:- origin/ master} "
23+ fi
1624
1725FAIL_ON_BREAKING=false
1826TARGET_FILE=" "
@@ -29,9 +37,21 @@ for arg in "$@"; do
2937 fi
3038done
3139
40+ # Detect current branch: GitHub Actions PR branch, or local git branch
41+ # Allow CURRENT_BRANCH env var to override for testing
42+ if [ -n " $CURRENT_BRANCH " ]; then
43+ # Use explicitly set CURRENT_BRANCH (for testing)
44+ :
45+ elif [ -n " $GITHUB_HEAD_REF " ]; then
46+ # Use GitHub Actions PR branch
47+ CURRENT_BRANCH=" $GITHUB_HEAD_REF "
48+ else
49+ # Use local git branch
50+ CURRENT_BRANCH=$( git branch --show-current 2> /dev/null || echo " " )
51+ fi
52+
3253# If --fail-on-breaking not explicitly set, determine based on branch name
3354if [ " $FAIL_ON_BREAKING " = false ]; then
34- CURRENT_BRANCH=${CURRENT_BRANCH:- $(git branch --show-current 2>/ dev/ null || echo " " )}
3555 if [[ " $CURRENT_BRANCH " == * breaking* ]]; then
3656 echo " Branch '$CURRENT_BRANCH ' contains 'breaking', allowing breaking changes"
3757 FAIL_ON_BREAKING=false
@@ -135,7 +155,7 @@ for file in $files; do
135155 echo " "
136156 echo " --- Breaking changes check ---"
137157 set +e
138- BREAKING_OUTPUT=$( docker run --rm -v " $( pwd) " :/current -v " $TEMP_DIR " :/base " $DOCKER_IMAGE " breaking --fail-on ERR --include-path-params /base/" $file " /current/" $file " 2>&1 )
158+ BREAKING_OUTPUT=$( docker run --rm -v " $( pwd) " :/current -v " $TEMP_DIR " :/base " $DOCKER_IMAGE " breaking --fail-on WARN --include-path-params /base/" $file " /current/" $file " 2>&1 )
139159 BREAKING_EXIT=$?
140160 set -e
141161
0 commit comments