feat: Add `allow-empty` input to support intentionally empty commits by leifdreizler · Pull Request #2 · semgrep/github-api-commit-action · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
74 changes: 74 additions & 0 deletions .github/workflows/test.yml
23 changes: 16 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ inputs:
default: 'false'
success-if-no-changes:
required: true
description: 'Whether to return success if no changes are detected: true/false'
description: 'Whether to return success if no changes are detected. Has no effect when allow-empty is true: true/false'
default: 'false'
allow-empty:
required: true
description: 'Whether to create an empty commit when there are no changes (supersedes success-if-no-changes): true/false'
default: 'false'
token:
required: true
Expand Down Expand Up @@ -129,13 +133,17 @@ runs:
done

if [[ "$additions" == "" && "$deletions" == "" ]]; then
echo "No changes to commit"
echo "any_changed=false" >> $GITHUB_OUTPUT

if [[ "${SUCCESS_IF_NO_CHANGES}" == "true" ]]; then
exit 0
if [[ "${ALLOW_EMPTY}" == "true" ]]; then
echo "No changes detected; creating an empty commit (allow-empty=true)"
else
exit 1
echo "No changes to commit"
echo "any_changed=false" >> $GITHUB_OUTPUT

if [[ "${SUCCESS_IF_NO_CHANGES}" == "true" ]]; then
exit 0
else
exit 1
fi
fi
fi

Expand All @@ -153,6 +161,7 @@ runs:
echo "deletions=$deletions" >> $GITHUB_OUTPUT
env:
SUCCESS_IF_NO_CHANGES: ${{ inputs.success-if-no-changes }}
ALLOW_EMPTY: ${{ inputs.allow-empty }}

- name: Commit changes
if: ${{ steps.additions-and-deletions.outputs.any_changed == 'true' }}
Expand Down
4 changes: 4 additions & 0 deletions docs/README.tmpl
Loading