@@ -66,21 +66,23 @@ console.log(`Running in ${baseDir}`);
6666 await git . tag ( getInput ( 'tag' ) . split ( ' ' ) , log )
6767 } else info ( '> No tag info provided.' )
6868
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.' )
8486
8587 endGroup ( )
8688 info ( '> Task completed.' )
@@ -175,13 +177,32 @@ async function checkInputs() {
175177 // #endregion
176178
177179 // #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 )
181187 setInput ( 'signoff' , undefined )
188+
182189 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' ) } )` )
185206 }
186207 // #endregion
187208}
@@ -190,6 +211,14 @@ function getInput(name: Input) {
190211 return getInputCore ( name )
191212}
192213
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+
193222function log ( err : any | Error , data ?: any ) {
194223 if ( data ) console . log ( data )
195224 if ( err ) error ( err )
0 commit comments