fix getting branch on fork branches
When running the version.py in CI, it only fetches a detached HEAD failing to get the reference. As I do not know very well if modifying the function will affect "normal" cases, I have preferred to use the variables provided by GHA to obtain the branch and the location of the repository.
This commit is contained in:
parent
e37bd4481f
commit
a311c4a2b0
6
.github/workflows/container.yml
vendored
6
.github/workflows/container.yml
vendored
@ -59,8 +59,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: "false"
|
||||
# make sure "make ci.container.build" can get the git branches
|
||||
fetch-depth: "0"
|
||||
|
||||
- name: Setup cache Python
|
||||
uses: actions/cache@v4
|
||||
@ -121,8 +119,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: "false"
|
||||
# make sure "make ci.container.test" can get the git branches
|
||||
fetch-depth: "0"
|
||||
|
||||
- if: ${{ matrix.emulation }}
|
||||
name: Setup QEMU
|
||||
@ -161,8 +157,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: "false"
|
||||
# make sure "make ci.container.push" can get the git history
|
||||
fetch-depth: "0"
|
||||
|
||||
- if: env.DOCKERHUB_USERNAME != ''
|
||||
name: Login to GHCR
|
||||
|
4
.github/workflows/integration.yml
vendored
4
.github/workflows/integration.yml
vendored
@ -119,8 +119,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: "false"
|
||||
# make sure "make ci.container.build" can get the git branches
|
||||
fetch-depth: "0"
|
||||
|
||||
- name: Setup cache Python
|
||||
uses: actions/cache@v4
|
||||
@ -182,8 +180,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: "false"
|
||||
# make sure "make ci.container.test" can get the git branches
|
||||
# fetch-depth: "0"
|
||||
|
||||
- if: ${{ matrix.emulation }}
|
||||
name: Setup QEMU
|
||||
|
7
manage
7
manage
@ -446,13 +446,6 @@ ci.container.build() {
|
||||
python -m searx.version freeze
|
||||
eval "$(python -m searx.version)"
|
||||
|
||||
# TODO: Remove this
|
||||
echo $VERSION_STRING
|
||||
echo $VERSION_TAG
|
||||
echo $DOCKER_TAG
|
||||
echo $GIT_URL
|
||||
echo $GIT_BRANCH
|
||||
|
||||
# Get the last git commit id
|
||||
version_gitcommit=$(echo "$VERSION_TAG" | cut -d+ -f2)
|
||||
build_msg CONTAINER "Last commit: $version_gitcommit"
|
||||
|
@ -41,6 +41,12 @@ def subprocess_run(args, **kwargs):
|
||||
|
||||
|
||||
def get_git_url_and_branch():
|
||||
# handle GHA directly
|
||||
if "GITHUB_REPOSITORY" in os.environ and "GITHUB_REF_NAME" in os.environ:
|
||||
git_url = f"https://github.com/{os.environ['GITHUB_REPOSITORY']}"
|
||||
git_branch = os.environ["GITHUB_REF_NAME"]
|
||||
return git_url, git_branch
|
||||
|
||||
try:
|
||||
ref = subprocess_run("git rev-parse --abbrev-ref @{upstream}")
|
||||
except subprocess.CalledProcessError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user