Fix git tag checkout in Gitea Actions workflow
Some checks failed
Build and Release / build (push) Failing after 10s
Some checks failed
Build and Release / build (push) Failing after 10s
- 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:
@@ -17,10 +17,14 @@ jobs:
|
||||
cd $GITHUB_WORKSPACE
|
||||
git init
|
||||
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
|
||||
git fetch origin ${{ github.ref }}
|
||||
|
||||
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
|
||||
# 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 }}
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user