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
28 changes: 28 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,34 @@ jobs:
with:
strategy: init
dry-run: true
test-action-clone-dry-run-no-empty:
# Expects no commit (unless the wiki test files are changed).
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: ./
with:
strategy: clone
dry-run: true
disable-empty-commits: true
test-action-init-dry-run-no-empty:
# Expects a commit either way as the init strategy creates an orphan branch.
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: ./
with:
strategy: init
dry-run: true
disable-empty-commits: true
test-action-real:
concurrency: ${{ github.workflow }}-real
permissions:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ is specific to GitHub wikis.
links. This helps ensure that the Markdown works in source control as well as
the wiki. The default is true.

- **`disable-empty-commits`:** By default, any triggering of this action will
result in a commit to the Wiki, even if that commit is empty.
If this option is true, a workflow run which would result in no changes
to the Wiki files, will no longer create an empty commit. The default is false.

#### `strategy:` input

There are some specific usecases where using `strategy: init` might be better
Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ inputs:
default is true.
required: true
default: true
disable-empty-commits:
description: >-
By default, any triggering of this action will result in a commit to the
Wiki, even if that commit is empty. If this option is true, a workflow
run which would result in no changes to the Wiki files, will no longer
create an empty commit. The default is false.
required: false
default: false
outputs:
wiki_url:
description: >-
Expand All @@ -94,3 +102,4 @@ runs:
INPUT_IGNORE: ${{ inputs.ignore }}
INPUT_DRY_RUN: ${{ inputs.dry-run }}
INPUT_PREPROCESS: ${{ inputs.preprocess }}
INPUT_DISABLE_EMPTY_COMMITS: ${{ inputs.disable-empty-commits }}
14 changes: 13 additions & 1 deletion cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,19 @@ if (core.getBooleanInput("preprocess")) {
}

await $`git add -Av`;
await $`git commit --allow-empty -m ${core.getInput("commit_message")}`;
if (core.getBooleanInput("disable_empty_commits")) {
try {
await $`git commit -m ${core.getInput("commit_message")}`;
} catch (e) {
if (e.exitCode === 1 && e.stderr.includes("nothing to commit")) {
console.log("nothing to commit, working tree clean");
} else {
throw e; // Unexpected error
}
}
} else {
await $`git commit --allow-empty -m ${core.getInput("commit_message")}`;
}

if (core.getBooleanInput("dry_run")) {
await $`git show`;
Expand Down
Loading