Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,19 @@ The following is an extended example with all available options.
# Optional. Disable dirty check and always try to create a commit and push
skip_dirty_check: true

# Optional. Skip internal call to `git fetch`
skip_fetch: true

# Optional. Skip internal call to `git checkout`
skip_checkout: true

# Optional. Prevents the shell from expanding filenames.
# Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
disable_globbing: true

# Optional. Create given branch name in local and remote repository.
create_branch: true

# Optional. Creates a new tag and pushes it to remote without creating a commit.
# Skips dirty check and changed files. Must be used with `tagging_message`.
create_git_tag_only: false
Expand Down Expand Up @@ -412,6 +421,7 @@ The steps in your workflow might look like this:
commit_message: ${{ steps.last-commit.outputs.message }}
commit_options: '--amend --no-edit'
push_options: '--force'
skip_fetch: true
```

See discussion in [#159](https://github.com/stefanzweifel/git-auto-commit-action/issues/159#issuecomment-845347950) for details.
Expand Down
24 changes: 12 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,27 @@ inputs:
description: Skip the check if the git repository is dirty and always try to create a commit.
required: false
default: false
skip_fetch:
description: Skip the call to git-fetch.
required: false
default: false
skip_checkout:
description: Skip the call to git-checkout.
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
create_branch:
description: Create new branch with the name of `branch`-input in local and remote repository, if it doesn't exist yet.
default: false
create_git_tag_only:
description: Perform a clean git tag and push, without commiting anything
required: false
default: false
internal_git_binary:
description: Internal use only! Path to git binary used to check if git is available. (Don't change this!)
default: git
skip_fetch:
description: "Deprecated: skip_fetch has been removed in v6. It does not have any effect anymore."
required: false
default: false
skip_checkout:
description: "Deprecated: skip_checkout has been removed in v6. It does not have any effect anymore."
required: false
default: false
create_branch:
description: "Deprecated: create_branch has been removed in v6. It does not have any effect anymore."
default: false


outputs:
Expand All @@ -88,7 +88,7 @@ outputs:
description: Value is "true", if a git tag was created using the `create_git_tag_only`-input.

runs:
using: 'node20'
using: 'node24'
main: 'index.js'

branding:
Expand Down
42 changes: 30 additions & 12 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ _log() {
}

_main() {
if "$INPUT_SKIP_FETCH"; then
_log "warning" "git-auto-commit: skip_fetch has been removed in v6. It does not have any effect anymore.";
fi

if "$INPUT_SKIP_CHECKOUT"; then
_log "warning" "git-auto-commit: skip_checkout has been removed in v6. It does not have any effect anymore.";
fi

if "$INPUT_CREATE_BRANCH"; then
_log "warning" "git-auto-commit: create_branch has been removed in v6. It does not have any effect anymore.";
fi

_check_if_git_is_available

_switch_to_repository
Expand All @@ -56,6 +44,8 @@ _main() {

_set_github_output "changes_detected" "true"

_switch_to_branch

_add_files

# Check dirty state of repo again using git-diff.
Expand Down Expand Up @@ -127,6 +117,34 @@ _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
_log "debug" "git-fetch will be executed.";
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
_log "debug" "git-checkout will be executed.";
# 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}";
Expand Down
Loading