File tree Expand file tree Collapse file tree 4 files changed +55
-1
lines changed Expand file tree Collapse file tree 4 files changed +55
-1
lines changed Original file line number Diff line number Diff line change 47
47
with :
48
48
strategy : init
49
49
dry-run : true
50
+ test-action-clone-dry-run-no-empty :
51
+ # Expects no commit (unless the wiki test files are changed).
52
+ strategy :
53
+ fail-fast : false
54
+ matrix :
55
+ os : [ubuntu-latest, windows-latest, macos-latest]
56
+ runs-on : ${{ matrix.os }}
57
+ steps :
58
+ - uses : actions/checkout@v3
59
+ - uses : ./
60
+ with :
61
+ strategy : clone
62
+ dry-run : true
63
+ disable-empty-commits : true
64
+ test-action-init-dry-run-no-empty :
65
+ # Expects a commit either way as the init strategy creates an orphan branch.
66
+ strategy :
67
+ fail-fast : false
68
+ matrix :
69
+ os : [ubuntu-latest, windows-latest, macos-latest]
70
+ runs-on : ${{ matrix.os }}
71
+ steps :
72
+ - uses : actions/checkout@v3
73
+ - uses : ./
74
+ with :
75
+ strategy : init
76
+ dry-run : true
77
+ disable-empty-commits : true
50
78
test-action-real :
51
79
concurrency : ${{ github.workflow }}-real
52
80
permissions :
Original file line number Diff line number Diff line change @@ -116,6 +116,11 @@ is specific to GitHub wikis.
116
116
links. This helps ensure that the Markdown works in source control as well as
117
117
the wiki. The default is true.
118
118
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
+
119
124
# ### `strategy:` input
120
125
121
126
There are some specific usecases where using `strategy : init` might be better
Original file line number Diff line number Diff line change @@ -71,6 +71,14 @@ inputs:
71
71
default is true.
72
72
required : true
73
73
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
74
82
outputs :
75
83
wiki_url :
76
84
description : >-
94
102
INPUT_IGNORE : ${{ inputs.ignore }}
95
103
INPUT_DRY_RUN : ${{ inputs.dry-run }}
96
104
INPUT_PREPROCESS : ${{ inputs.preprocess }}
105
+ INPUT_DISABLE_EMPTY_COMMITS : ${{ inputs.disable-empty-commits }}
Original file line number Diff line number Diff line change @@ -92,7 +92,19 @@ if (core.getBooleanInput("preprocess")) {
92
92
}
93
93
94
94
await $ `git add -Av` ;
95
- await $ `git commit --allow-empty -m ${ core . getInput ( "commit_message" ) } ` ;
95
+ if ( core . getBooleanInput ( "disable_empty_commits" ) ) {
96
+ try {
97
+ await $ `git commit -m ${ core . getInput ( "commit_message" ) } ` ;
98
+ } catch ( e ) {
99
+ if ( e . exitCode === 1 && e . stderr . includes ( "nothing to commit" ) ) {
100
+ console . log ( "nothing to commit, working tree clean" ) ;
101
+ } else {
102
+ throw e ; // Unexpected error
103
+ }
104
+ }
105
+ } else {
106
+ await $ `git commit --allow-empty -m ${ core . getInput ( "commit_message" ) } ` ;
107
+ }
96
108
97
109
if ( core . getBooleanInput ( "dry_run" ) ) {
98
110
await $ `git show` ;
You can’t perform that action at this time.
0 commit comments