mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-11 19:56:03 +00:00
fix: detect branch from GitHub Actions env vars in wrapper
In CI, git is in detached HEAD state, so git rev-parse returns 'HEAD'. Use GITHUB_REF and GITHUB_BASE_REF to properly detect release branches in GitHub Actions workflows. This ensures pre-commit hooks in CI can correctly identify when running against release branches and set the appropriate UV index URLs.
This commit is contained in:
parent
451f1e5fd2
commit
1c557b87cb
1 changed files with 13 additions and 3 deletions
|
|
@ -8,9 +8,19 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Detect current branch and target branch
|
# Detect current branch and target branch
|
||||||
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
|
# In GitHub Actions, use GITHUB_REF/GITHUB_BASE_REF
|
||||||
# For feature branches, check what branch they're merging into
|
if [[ -n "${GITHUB_REF:-}" ]]; then
|
||||||
TARGET_BRANCH=$(git rev-parse --abbrev-ref HEAD@{upstream} 2>/dev/null | sed 's|origin/||' || echo "")
|
BRANCH="${GITHUB_REF#refs/heads/}"
|
||||||
|
else
|
||||||
|
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For PRs, check the target branch
|
||||||
|
if [[ -n "${GITHUB_BASE_REF:-}" ]]; then
|
||||||
|
TARGET_BRANCH="${GITHUB_BASE_REF}"
|
||||||
|
else
|
||||||
|
TARGET_BRANCH=$(git rev-parse --abbrev-ref HEAD@{upstream} 2>/dev/null | sed 's|origin/||' || echo "")
|
||||||
|
fi
|
||||||
|
|
||||||
echo "[uv-run-with-index] Current branch: '$BRANCH'" >&2
|
echo "[uv-run-with-index] Current branch: '$BRANCH'" >&2
|
||||||
echo "[uv-run-with-index] Target branch: '$TARGET_BRANCH'" >&2
|
echo "[uv-run-with-index] Target branch: '$TARGET_BRANCH'" >&2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue