checkout/entrypoint.sh
2025-10-22 12:41:55 +00:00

21 lines
655 B
Bash
Executable file

#!/bin/bash -e
URL="${GITHUB_SERVER_URL/\/\//\/\/$GITHUB_REPOSITORY_OWNER:$INPUT_TOKEN@}/$GITHUB_REPOSITORY"
git init -b main
git remote add origin "$URL"
git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin "$GITHUB_SHA"
git checkout --progress --force -B main "$GITHUB_SHA"
if [ "$INPUT_SUBMODULES" = true ]; then
git submodule update --init --single-branch
elif [ "$INPUT_SUBMODULES" = recursive ]; then
git submodule update --init --single-branch --recursive
fi
if [ -n "$INPUT_SUBPATH" ]; then (
shopt -s dotglob
git sparse-checkout set "$INPUT_SUBPATH"
mv "$INPUT_SUBPATH"/* .
rmdir "$INPUT_SUBPATH"
) fi