File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed
Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 88 description : ' Arguments to pass to the Dockerfile entrypoint.'
99 required : true
1010 default : ' --help'
11+ outputs :
12+ commitUrl :
13+ description : ' The URL of the commit if that was created successfully.'
1114runs :
1215 using : ' docker'
1316 image : ' Dockerfile'
Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
12const yargs = require ( "yargs" ) ;
23const CURRENT_VERSION = require ( "./package.json" ) . version ;
34
89 checkIfBranchExists,
910} = require ( "./index" ) ;
1011
12+ const appendLineToFile = ( filename , line ) => {
13+ fs . appendFile ( filename , `${ line } \n` , function ( err ) {
14+ if ( err ) throw err ;
15+ console . log ( `Saved data to ${ filename } .` ) ;
16+ } ) ;
17+ } ;
18+
1119yargs
1220 . command (
1321 "commit" ,
8391 commitDescription
8492 )
8593 . then ( ( response ) => {
86- console . log ( JSON . stringify ( response , null , 2 ) ) ;
94+ console . log ( `Commit created: ${ response . commitUrl } ` ) ;
95+ if ( ! ! process . env . GITHUB_OUTPUT ) {
96+ appendLineToFile (
97+ process . env . GITHUB_OUTPUT ,
98+ `commitUrl=${ response . commitUrl } `
99+ ) ;
100+ }
87101 } )
88102 . catch ( ( error ) => {
89103 console . error ( "Failed to create commit:" , error . message ) ;
@@ -120,7 +134,6 @@ yargs
120134 checkIfBranchExists ( owner , repo , branch )
121135 . then ( ( response ) => {
122136 const n = response ? "a" : "no" ;
123- //console.log(JSON.stringify(response, null, 2));
124137 console . log (
125138 `Repository ${ owner } /${ repo } has ${ n } branch named '${ branch } '`
126139 ) ;
Original file line number Diff line number Diff line change @@ -178,7 +178,10 @@ async function createCommitOnBranch(
178178 const response = await client
179179 . mutation ( graphqlRequest . query , graphqlRequest . variables )
180180 . toPromise ( ) ;
181- return response ;
181+ return {
182+ data : response ,
183+ commitUrl : response ?. data ?. createCommitOnBranch ?. commit ?. url || null
184+ } ;
182185 } catch ( error ) {
183186 console . error (
184187 `Error while performing commit action via GraphQL API: ${ error . message } `
You can’t perform that action at this time.
0 commit comments