Skip to content

Commit cb0c245

Browse files
committed
Add "disable-empty-commits" option
As discussed in 80. Note: I'm very much not a TS/JS dev, so I hope I've gotten it right ;-) Also wasn't sure how to add tests for this, but hopefully you don't mind guiding me on that ? Feel free to push to my branch.
1 parent b7e552d commit cb0c245

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ is specific to GitHub wikis.
116116
links. This helps ensure that the Markdown works in source control as well as
117117
the wiki. The default is true.
118118

119+
- **`disable-empty-commits`:** By default, any triggering of this action will
120+
result in a commit to the Wiki, even if that commit is empty.
121+
If this option is true, a workflow run which would result in no changes
122+
to the Wiki files, will no longer create an empty commit. The default is false.
123+
119124
#### `strategy:` input
120125

121126
There are some specific usecases where using `strategy: init` might be better

action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ inputs:
7171
default is true.
7272
required: true
7373
default: true
74+
disable-empty-commits:
75+
description: >-
76+
By default, any triggering of this action will result in a commit to the
77+
Wiki, even if that commit is empty. If this option is true, a workflow
78+
run which would result in no changes to the Wiki files, will no longer
79+
create an empty commit. The default is false.
80+
required: false
81+
default: false
7482
outputs:
7583
wiki_url:
7684
description: >-
@@ -94,3 +102,4 @@ runs:
94102
INPUT_IGNORE: ${{ inputs.ignore }}
95103
INPUT_DRY_RUN: ${{ inputs.dry-run }}
96104
INPUT_PREPROCESS: ${{ inputs.preprocess }}
105+
INPUT_DISABLE_EMPTY_COMMITS: ${{ inputs.disable-empty-commits }}

cli.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ if (core.getBooleanInput("preprocess")) {
9292
}
9393

9494
await $`git add -Av`;
95-
await $`git commit --allow-empty -m ${core.getInput("commit_message")}`;
95+
if (core.getBooleanInput("disable_empty_commits")) {
96+
await $`git commit -m ${core.getInput("commit_message")}`;
97+
} else {
98+
await $`git commit --allow-empty -m ${core.getInput("commit_message")}`;
99+
}
96100

97101
if (core.getBooleanInput("dry_run")) {
98102
await $`git show`;

0 commit comments

Comments
 (0)