Add skip_push input option (#401)

Co-authored-by: Stefan Zweifel <stefan@stefanzweifel.dev>
This commit is contained in:
Koen van Zuijlen
2025-12-17 20:23:26 +01:00
committed by GitHub
parent 65c56779c9
commit 1e49d5001f
4 changed files with 30 additions and 0 deletions

View File

@@ -115,6 +115,9 @@ The following is an extended example with all available options.
# Optional. Skip internal call to `git checkout`
skip_checkout: true
# Optional. Skip internal call to `git push`
skip_push: true
# Optional. Prevents the shell from expanding filenames.
# Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html

View File

@@ -68,6 +68,10 @@ inputs:
description: Skip the call to git-checkout.
required: false
default: false
skip_push:
description: Skip the call to git-push.
required: false
default: false
disable_globbing:
description: Stop the shell from expanding filenames (https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html)
default: false

View File

@@ -191,6 +191,10 @@ _tag_commit() {
}
_push_to_github() {
if "$INPUT_SKIP_PUSH"; then
_log "debug" "git-push will not be executed.";
return
fi
echo "INPUT_BRANCH value: $INPUT_BRANCH";

View File

@@ -38,6 +38,7 @@ setup() {
export INPUT_SKIP_DIRTY_CHECK=false
export INPUT_SKIP_FETCH=false
export INPUT_SKIP_CHECKOUT=false
export INPUT_SKIP_PUSH=false
export INPUT_DISABLE_GLOBBING=false
export INPUT_CREATE_BRANCH=false
export INPUT_INTERNAL_GIT_BINARY=git
@@ -352,6 +353,24 @@ cat_github_output() {
assert_equal $current_sha $remote_sha
}
@test "If SKIP_PUSH is true git-push will not be called" {
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
INPUT_SKIP_PUSH=true
run git_auto_commit
assert_success
assert_line "::debug::git-push will not be executed."
# Assert that the sha values are not equal on local and remote
current_sha="$(git rev-parse --verify --short ${FAKE_DEFAULT_BRANCH})"
remote_sha="$(git rev-parse --verify --short origin/${FAKE_DEFAULT_BRANCH})"
refute [assert_equal $current_sha $remote_sha]
}
@test "It can checkout a different branch" {
# Create foo-branch and then immediately switch back to ${FAKE_DEFAULT_BRANCH}
git checkout -b foo