new args: * target/working directory; * fetch tags on demand

This commit is contained in:
Vital A Pi 2026-10-11 13:39:25 +03:00
commit 7fda4264f4

View file

@ -23,6 +23,14 @@ inputs:
git_object_format:
required: true
default: sha256
cwd:
description: 'Create and change working dir before checkout'
required: true
default: '.'
fetch_tags:
description: 'Fetch tags after all'
required: true
default: false
runs:
using: 'composite'
@ -30,6 +38,8 @@ runs:
- name: Run git checkout commands
shell: bash
run: |
mkdir -vp "${{ inputs.cwd }}"
cd "${{ inputs.cwd }}"
shopt -s dotglob
rm -rf *
git init --object-format=${{ inputs.git_object_format }} -b main .
@ -37,3 +47,7 @@ runs:
export AH="Authorization: Basic $(printf 'x-access-token:${{ inputs.token }}' | base64 | tr -d '\n')"
git --config-env=http.extraheader=AH fetch --depth 2 origin "${{ inputs.sha }}"
git reset --hard FETCH_HEAD
if [ ${{ inputs.fetch_tags }} == 'true' ]; then
printf 'Fetching tags, as requested\n'
git --config-env=http.extraheader=AH fetch --tags
fi