Fix git tag checkout in Gitea Actions workflow

- For tags: fetch with explicit ref mapping to refs/tags/
- For branches: fetch with explicit ref mapping to refs/remotes/origin/
- Properly checkout tag refs using refs/tags/ path
- Fixes 'pathspec did not match any file(s)' error on tag builds
This commit is contained in:
Ducky SSH User
2025-12-20 06:24:56 +00:00
parent 66734923cb
commit ad212e452e

View File

@@ -17,10 +17,14 @@ jobs:
cd $GITHUB_WORKSPACE cd $GITHUB_WORKSPACE
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 }}
if [[ "${{ github.ref }}" == refs/tags/* ]]; then if [[ "${{ github.ref }}" == refs/tags/* ]]; then
git checkout ${{ github.ref_name }} # For tags, fetch the specific tag and checkout the commit it points to
git fetch origin ${{ github.ref }}:refs/tags/${{ github.ref_name }}
git checkout refs/tags/${{ github.ref_name }}
else else
# For branches, fetch and checkout with tracking
git fetch origin ${{ github.ref_name }}:refs/remotes/origin/${{ github.ref_name }}
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }} git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
fi fi