Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
sed -i 's/--abort-on-container-exit/-d/' bin/first-build.sh
TAB=$'\t'
export FALLBACK_BRANCH=$([ "$GITHUB_BRANCH" == "master" ] && echo "main" && echo "master" || echo "develop")
git submodule foreach bash -c '(git checkout "${GITHUB_BRANCH}" || git checkout main || git checkout develop || git checkout master || git checkout "${FALLBACK_BRANCH}") && git pull'
./bin/checkout-submodules.sh "$GITHUB_BRANCH" "$FALLBACK_BRANCH"
git submodule foreach git rev-parse --abbrev-ref HEAD

- name: Run Script
Expand Down
25 changes: 25 additions & 0 deletions bin/checkout-submodules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

GITHUB_BRANCH="$1"
FALLBACK_BRANCH="$2"

git submodule foreach --recursive bash -c '
GITHUB_BRANCH="$1"
FALLBACK_BRANCH="$2"

for b in "$GITHUB_BRANCH" main develop master "$FALLBACK_BRANCH"; do
echo "Trying branch: $b"
if git ls-remote --exit-code origin "$b" &>/dev/null; then
echo "Found branch $b in remote. Checking out..."
if git checkout -B "$b" "origin/$b"; then
echo "Pulling latest changes for $b..."
git pull
exit 0
fi
else
echo "Branch $b not found in remote."
fi
done

echo "No matching branch found in submodule $name"
' _ "$GITHUB_BRANCH" "$FALLBACK_BRANCH"