5
5
6
6
echo " Running prebuild SUMMARY.md selection..."
7
7
8
- # Get the current git branch
9
- CURRENT_BRANCH=$( git branch --show-current 2> /dev/null || echo " unknown" )
8
+ # Default branch
9
+ CURRENT_BRANCH=" unknown"
10
10
11
- # If branch detection fails, try CI environment variables
12
- if [ " $CURRENT_BRANCH " = " unknown" ]; then
11
+ # Check for Vercel environment variables first
12
+ if [ -n " $VERCEL_GIT_COMMIT_REF " ]; then
13
+ CURRENT_BRANCH=$VERCEL_GIT_COMMIT_REF
14
+ echo " Branch detected from VERCEL_GIT_COMMIT_REF: $CURRENT_BRANCH "
15
+ # Get the current git branch (fallback)
16
+ elif git rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
17
+ CURRENT_BRANCH=$( git branch --show-current 2> /dev/null || echo " unknown" )
18
+ echo " Branch detected from git: $CURRENT_BRANCH "
19
+ # Try other CI environment variables
20
+ else
13
21
# Try GitHub Actions env var
14
22
if [ -n " $GITHUB_REF " ]; then
15
23
CURRENT_BRANCH=${GITHUB_REF# refs/ heads/ }
24
+ echo " Branch detected from GITHUB_REF: $CURRENT_BRANCH "
16
25
# Try GitLab CI env var
17
26
elif [ -n " $CI_COMMIT_BRANCH " ]; then
18
27
CURRENT_BRANCH=$CI_COMMIT_BRANCH
28
+ echo " Branch detected from CI_COMMIT_BRANCH: $CURRENT_BRANCH "
29
+ # Try general CI environment variables
30
+ elif [ -n " $BRANCH_NAME " ]; then
31
+ CURRENT_BRANCH=$BRANCH_NAME
32
+ echo " Branch detected from BRANCH_NAME: $CURRENT_BRANCH "
33
+ else
34
+ echo " Could not detect branch from any source, defaulting to 'develop'"
35
+ CURRENT_BRANCH=" develop"
19
36
fi
20
37
fi
21
38
22
- echo " Detected branch: $CURRENT_BRANCH "
39
+ echo " Final detected branch: $CURRENT_BRANCH "
23
40
24
41
# Ensure the config directory exists
25
42
if [ ! -d " src/config" ]; then
@@ -39,6 +56,10 @@ if [ ! -f "src/config/SUMMARY.md.main" ]; then
39
56
exit 1
40
57
fi
41
58
59
+ # Add debug information about available environment variables
60
+ echo " Available environment variables:"
61
+ env | sort | grep -E ' GIT|VERCEL|BRANCH|CI' || echo " No relevant environment variables found"
62
+
42
63
# Select the appropriate SUMMARY.md based on branch
43
64
if [ " $CURRENT_BRANCH " = " main" ] || [ " $CURRENT_BRANCH " = " master" ]; then
44
65
echo " Using main branch SUMMARY.md"
0 commit comments