Skip to content

Commit 21c51e8

Browse files
authored
Refactor branch checkout in classroom workflow
Updated the workflow to determine branch name safely before checking out.
1 parent f6a2df8 commit 21c51e8

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.github/workflows/classroom.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,12 @@ jobs:
186186
run: |
187187
# Ensure full history
188188
git fetch origin main
189-
git checkout "${GITHUB_REF##*/}"
190-
git branch --set-upstream-to=origin/main "${GITHUB_REF##*/}"
189+
190+
# Determine branch name safely
191+
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
192+
echo "Using branch: $BRANCH_NAME"
193+
git checkout "$BRANCH_NAME"
194+
git branch --set-upstream-to=origin/main "$BRANCH_NAME"
191195

192196
# Check for test files
193197
has_tests=$(find src/test/java -type f -name "*.java" | grep -q . && echo "true" || echo "false")

0 commit comments

Comments
 (0)