Clone branch if there is a ref_name

This commit is contained in:
2025-02-10 21:18:55 +01:00
parent 881ca600a3
commit 7a98bacd15
+13 -4
View File
@@ -10,11 +10,20 @@ runs:
run: |
set -e
echo 'Ref ${{ gitea.ref }}'
echo 'Name ${{ gitea.ref_name }}'
echo 'Type ${{ gitea.ref_type }}'
cd ${{ gitea.workspace }}
git init -b main
git remote add origin ${{ gitea.server_url }}/${{ gitea.repository }}.git
git fetch --depth 1 origin ${{ gitea.sha }}
git checkout FETCH_HEAD
if [ -z "${{ gitea.ref_name }}" ]; then
git init -b main
git remote add origin ${{ gitea.server_url }}/${{ gitea.repository }}.git
git fetch --depth 1 origin ${{ gitea.sha }}
git checkout FETCH_HEAD
else
git clone -b ${{ gitea.ref_name }} --single-branch ${{ gitea.server_url }}/${{ gitea.repository }}.git .
fi
echo "The ${{ gitea.repository }} repository has been cloned to the runner."
branding:
icon: "git-commit"