Fix git checkout for tag builds in Gitea Actions
Some checks failed
Build and Release / build (push) Failing after 0s
Build and Release / docker-build (push) Failing after 0s

- Add conditional logic to handle tag vs branch checkouts
- Tags don't exist on 'origin/tagname' so use direct checkout
- Branches can be checked out as 'origin/branchname'
- Fixes 'fatal: origin/v0.0.1 is not a commit' error
This commit is contained in:
Ducky SSH User
2025-12-20 06:09:43 +00:00
parent 6c6bc0d57f
commit 89fb5bbf7d

View File

@@ -18,7 +18,11 @@ jobs:
git init git init
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
git fetch origin ${{ github.ref }} git fetch origin ${{ github.ref }}
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
git checkout ${{ github.ref_name }}
else
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }} git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
fi
- name: Set up Go - name: Set up Go
run: | run: |
@@ -31,7 +35,7 @@ jobs:
id: version id: version
run: | run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/} VERSION=${{ github.ref_name }}
else else
VERSION=dev-${{ github.sha }} VERSION=dev-${{ github.sha }}
fi fi
@@ -148,7 +152,11 @@ jobs:
git init git init
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
git fetch origin ${{ github.ref }} git fetch origin ${{ github.ref }}
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
git checkout ${{ github.ref_name }}
else
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }} git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
fi
- name: Set up Docker - name: Set up Docker
run: | run: |