Restore skip_fetch, skip_checkout, create_branch

This commit is contained in:
Stefan Zweifel
2025-09-17 11:02:55 +02:00
parent 01d77ca6cb
commit 2da8d963b4
3 changed files with 49 additions and 11 deletions

View File

@@ -56,6 +56,8 @@ _main() {
_set_github_output "changes_detected" "true"
_switch_to_branch
_add_files
# Check dirty state of repo again using git-diff.
@@ -127,6 +129,32 @@ _check_if_repository_is_in_detached_state() {
fi
}
_switch_to_branch() {
echo "INPUT_BRANCH value: $INPUT_BRANCH";
# Fetch remote to make sure that repo can be switched to the right branch.
if "$INPUT_SKIP_FETCH"; then
_log "debug" "git-fetch will not be executed.";
else
git fetch --depth=1;
fi
# If `skip_checkout`-input is true, skip the entire checkout step.
if "$INPUT_SKIP_CHECKOUT"; then
_log "debug" "git-checkout will not be executed.";
else
# Create new local branch if `create_branch`-input is true
if "$INPUT_CREATE_BRANCH"; then
# shellcheck disable=SC2086
git checkout -B $INPUT_BRANCH --;
else
# Switch to branch from current Workflow run
# shellcheck disable=SC2086
git checkout $INPUT_BRANCH --;
fi
fi
}
_add_files() {
echo "INPUT_ADD_OPTIONS: ${INPUT_ADD_OPTIONS}";
_log "debug" "Apply add options ${INPUT_ADD_OPTIONS}";