@@ -66,21 +66,23 @@ console.log(`Running in ${baseDir}`);
66
66
await git . tag ( getInput ( 'tag' ) . split ( ' ' ) , log )
67
67
} else info ( '> No tag info provided.' )
68
68
69
- info ( '> Pushing commit to repo...' )
70
- await git . push ( 'origin' , getInput ( 'branch' ) , { '--set-upstream' : null } , log )
71
-
72
- if ( getInput ( 'tag' ) ) {
73
- info ( '> Pushing tags to repo...' )
74
- await git . pushTags ( 'origin' , ( e , d ?) => log ( undefined , e || d ) ) . catch ( ( ) => {
75
- info ( '> Tag push failed: deleting remote tag and re-pushing...' )
76
- return git . push ( undefined , undefined , {
77
- '--delete' : null ,
78
- 'origin' : null ,
79
- [ getInput ( 'tag' ) . split ( ' ' ) . filter ( w => ! w . startsWith ( '-' ) ) [ 0 ] ] : null
80
- } , log )
81
- . pushTags ( 'origin' , log )
82
- } )
83
- } else info ( '> No tags to push.' )
69
+ if ( getInput ( 'push' ) ) {
70
+ info ( '> Pushing commit to repo...' )
71
+ await git . push ( 'origin' , getInput ( 'branch' ) , { '--set-upstream' : null } , log )
72
+
73
+ if ( getInput ( 'tag' ) ) {
74
+ info ( '> Pushing tags to repo...' )
75
+ await git . pushTags ( 'origin' , ( e , d ?) => log ( undefined , e || d ) ) . catch ( ( ) => {
76
+ info ( '> Tag push failed: deleting remote tag and re-pushing...' )
77
+ return git . push ( undefined , undefined , {
78
+ '--delete' : null ,
79
+ 'origin' : null ,
80
+ [ getInput ( 'tag' ) . split ( ' ' ) . filter ( w => ! w . startsWith ( '-' ) ) [ 0 ] ] : null
81
+ } , log )
82
+ . pushTags ( 'origin' , log )
83
+ } )
84
+ } else info ( '> No tags to push.' )
85
+ } else info ( '> Not pushing anything.' )
84
86
85
87
endGroup ( )
86
88
info ( '> Task completed.' )
@@ -175,13 +177,32 @@ async function checkInputs() {
175
177
// #endregion
176
178
177
179
// #region signoff
178
- if ( getInput ( 'signoff' ) ) try {
179
- const parsed = JSON . parse ( getInput ( 'signoff' ) )
180
- if ( typeof parsed == 'boolean' && ! parsed )
180
+ if ( getInput ( 'signoff' ) ) {
181
+ const parsed = parseBool ( getInput ( 'signoff' ) )
182
+
183
+ if ( parsed === undefined )
184
+ throw new Error ( `"${ getInput ( 'signoff' ) } " is not a valid value for the 'signoff' input: only "true" and "false" are allowed.` )
185
+
186
+ if ( ! parsed )
181
187
setInput ( 'signoff' , undefined )
188
+
182
189
debug ( `Current signoff option: ${ getInput ( 'signoff' ) } (${ typeof getInput ( 'signoff' ) } )` )
183
- } catch {
184
- throw new Error ( `"${ getInput ( 'signoff' ) } " is not a valid value for the 'signoff' input: only "true" and "false" are allowed.` )
190
+ }
191
+
192
+ // #endregion
193
+
194
+ // #region push
195
+ setDefault ( 'push' , 'true' )
196
+ if ( getInput ( 'push' ) ) { // It's just to scope the parsed constant
197
+ const parsed = parseBool ( getInput ( 'push' ) )
198
+
199
+ if ( parsed === undefined )
200
+ throw new Error ( `"${ getInput ( 'push' ) } " is not a valid value for the 'push' input: only "true" and "false" are allowed.` )
201
+
202
+ if ( ! parsed )
203
+ setInput ( 'push' , undefined )
204
+
205
+ debug ( `Current push option: ${ getInput ( 'push' ) } (${ typeof getInput ( 'push' ) } )` )
185
206
}
186
207
// #endregion
187
208
}
@@ -190,6 +211,14 @@ function getInput(name: Input) {
190
211
return getInputCore ( name )
191
212
}
192
213
214
+ function parseBool ( value : any ) {
215
+ try {
216
+ const parsed = JSON . parse ( value )
217
+ if ( typeof parsed == 'boolean' )
218
+ return parsed
219
+ } catch { }
220
+ }
221
+
193
222
function log ( err : any | Error , data ?: any ) {
194
223
if ( data ) console . log ( data )
195
224
if ( err ) error ( err )
0 commit comments