Fix git checkout for tag builds in Gitea Actions
- 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:
@@ -18,7 +18,11 @@ jobs:
|
||||
git init
|
||||
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
|
||||
git fetch origin ${{ github.ref }}
|
||||
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
|
||||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||
git checkout ${{ github.ref_name }}
|
||||
else
|
||||
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
|
||||
fi
|
||||
|
||||
- name: Set up Go
|
||||
run: |
|
||||
@@ -31,7 +35,7 @@ jobs:
|
||||
id: version
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
VERSION=${{ github.ref_name }}
|
||||
else
|
||||
VERSION=dev-${{ github.sha }}
|
||||
fi
|
||||
@@ -148,7 +152,11 @@ jobs:
|
||||
git init
|
||||
git remote add origin ${{ github.server_url }}/${{ github.repository }}.git
|
||||
git fetch origin ${{ github.ref }}
|
||||
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
|
||||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||
git checkout ${{ github.ref_name }}
|
||||
else
|
||||
git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
|
||||
fi
|
||||
|
||||
- name: Set up Docker
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user