@@ -12,6 +12,7 @@ const { shortPolling } = require('./utils/polling');
1212async function storybook ( serve , options ) {
1313 let type = / ^ h t t p s ? : \/ \/ / . test ( serve ) ? 'url' : 'dir' ;
1414 let storybookConfig = options . config ? options . config : defaultSmartUIConfig . storybook ;
15+ const buildName = options . buildName ? options . buildName : "" ;
1516
1617 if ( type === 'url' ) {
1718 await validateStorybookUrl ( serve ) ;
@@ -113,6 +114,29 @@ async function storybook(serve, options) {
113114 }
114115
115116 let commit = await getLastCommit ( ) ;
117+ let baseLine = process . env . BASELINE_BRANCH ;
118+ let currentBranch = process . env . CURRENT_BRANCH ;
119+ if ( baseLine !== null && baseLine !== undefined ) {
120+ if ( baseLine === '' ) {
121+ const error = {
122+ "error" : "MISSING_BRANCH_NAME" ,
123+ "message" : "Error : The baseline branch name environment variable cannot be empty."
124+ } ;
125+ console . log ( JSON . stringify ( error , null , 2 ) ) ;
126+ process . exit ( 1 ) ;
127+ }
128+ }
129+
130+ if ( currentBranch !== null && currentBranch !== undefined ) {
131+ if ( currentBranch === '' ) {
132+ const error = {
133+ "error" : "MISSING_BRANCH_NAME" ,
134+ "message" : "Error : The current branch name environment variable cannot be empty."
135+ } ;
136+ console . log ( JSON . stringify ( error , null , 2 ) ) ;
137+ process . exit ( 1 ) ;
138+ }
139+ }
116140 let payload = {
117141 downloadURL : url . substring ( url . search ( / .c o m / ) + 5 , url . search ( / .z i p / ) + 4 ) ,
118142 uploadId : uploadId ,
@@ -125,12 +149,14 @@ async function storybook(serve, options) {
125149 customViewports : storybookConfig . customViewports
126150 } ,
127151 git : {
128- branch : commit . branch ,
129- commitId : commit . shortHash ,
130- commitAuthor : commit . author . name ,
131- commitMessage : commit . subject ,
152+ branch : currentBranch || commit . branch || '' ,
153+ baselineBranch : baseLine || '' ,
154+ commitId : commit . shortHash ,
155+ commitAuthor : commit . author . name ,
156+ commitMessage : commit . subject ,
132157 githubURL : process . env . GITHUB_URL || '' ,
133- }
158+ } ,
159+ buildName : buildName ,
134160 }
135161
136162 // Call static render API
0 commit comments