@@ -12,6 +12,8 @@ const routesLocationInputName = 'routes_location';
1212const buildTimeoutInMinutesInputName = 'build_timeout_in_minutes' ;
1313const configFileLocationInputName = 'config_file_location' ;
1414const apiTokenInputName = 'azure_static_web_apps_api_token' ;
15+ const deploymentEnvironmentInputName = 'deployment_environment' ;
16+ const productionBranchInputName = 'production_branch' ;
1517
1618async function run ( ) {
1719 const envVarFilePath : string = path . join ( __dirname , 'env.list' ) ;
@@ -33,7 +35,7 @@ async function run() {
3335 bash . line ( tl . getInput ( 'args' , false ) ) ;
3436
3537 await createDockerEnvVarFile ( envVarFilePath ) ;
36-
38+
3739 const options = {
3840 failOnStdErr : false
3941 } ;
@@ -59,9 +61,9 @@ async function createDockerEnvVarFile(envVarFilePath: string) {
5961 systemVariableNames . add ( envVarName )
6062 }
6163
62- const addInputStringToString = ( envVarName : string , envVarValue : string , inputName : string , ) => {
64+ const addInputStringToString = ( envVarName : string , envVarValue : string , inputName : string , ) => {
6365 if ( envVarValue . includes ( "\n" ) ) {
64- throw "Input " + inputName + " is a multiline string and cannot be added to the build environment." ;
66+ throw "Input " + inputName + " is a multiline string and cannot be added to the build environment." ;
6567 }
6668
6769 addSystemVariableToString ( envVarName , envVarValue )
@@ -76,6 +78,8 @@ async function createDockerEnvVarFile(envVarFilePath: string) {
7678 const routesLocation : string = tl . getInput ( routesLocationInputName , false ) || "" ;
7779 const buildTimeoutInMinutes : string = tl . getInput ( buildTimeoutInMinutesInputName , false ) || "" ;
7880 const configFileLocation : string = tl . getInput ( configFileLocationInputName , false ) || "" ;
81+ const deploymentEnvironment : string = tl . getInput ( deploymentEnvironmentInputName , false ) || "" ;
82+ const productionBranch : string = tl . getInput ( productionBranchInputName , false ) || "" ;
7983
8084 const skipAppBuild : boolean = tl . getBoolInput ( 'skip_app_build' , false ) ;
8185 const skipApiBuild : boolean = tl . getBoolInput ( 'skip_api_build' , false ) ;
@@ -97,6 +101,8 @@ async function createDockerEnvVarFile(envVarFilePath: string) {
97101 addInputStringToString ( "ROUTES_LOCATION" , routesLocation , routesLocationInputName ) ;
98102 addInputStringToString ( "BUILD_TIMEOUT_IN_MINUTES" , buildTimeoutInMinutes , buildTimeoutInMinutesInputName ) ;
99103 addInputStringToString ( "CONFIG_FILE_LOCATION" , configFileLocation , configFileLocationInputName ) ;
104+ addInputStringToString ( "DEPLOYMENT_ENVIRONMENT" , deploymentEnvironment , deploymentEnvironmentInputName ) ;
105+ addInputStringToString ( "PRODUCTION_BRANCH" , productionBranch , productionBranchInputName ) ;
100106
101107 addSystemVariableToString ( "SKIP_APP_BUILD" , skipAppBuild . toString ( ) ) ;
102108 addSystemVariableToString ( "SKIP_API_BUILD" , skipApiBuild . toString ( ) ) ;
@@ -114,17 +120,17 @@ async function createDockerEnvVarFile(envVarFilePath: string) {
114120 addSystemVariableToString ( "IS_PULL_REQUEST" , "" ) ;
115121 addSystemVariableToString ( "BASE_BRANCH" , "" ) ;
116122 addSystemVariableToString ( "REPOSITORY_BASE" , containerWorkingDir ) ;
117- addSystemVariableToString ( "BRANCH" , process . env . BUILD_SOURCEBRANCHNAME || "" ) ;
123+ addSystemVariableToString ( "BRANCH" , process . env . BUILD_SOURCEBRANCHNAME || process . env . BUILD_SOURCEBRANCH || "" ) ;
118124 addSystemVariableToString ( "DEPLOYMENT_ACTION" , "upload" ) ;
119125
120126 const denylistString = await fs . promises . readFile ( path . join ( __dirname , 'envVarDenylist.json' ) , 'utf8' ) ;
121127 const denylist = JSON . parse ( denylistString ) ;
122128
123- Object . keys ( process . env ) . forEach ( ( envVarKey : string ) => {
129+ Object . keys ( process . env ) . forEach ( ( envVarKey : string ) => {
124130 const envVarValue = process . env [ envVarKey ] ;
125131
126132 if ( envVarValue . includes ( "\n" ) ) {
127- tl . warning ( "Environment variable " + envVarKey + " is a multiline string and cannot be added to the build environment." ) ;
133+ tl . warning ( "Environment variable " + envVarKey + " is a multiline string and cannot be added to the build environment." ) ;
128134 return ;
129135 }
130136
@@ -133,23 +139,23 @@ async function createDockerEnvVarFile(envVarFilePath: string) {
133139 return ;
134140 }
135141
136- if ( ! denylist . includes ( envVarKey . toUpperCase ( ) ) ) {
142+ if ( ! denylist . includes ( envVarKey . toUpperCase ( ) ) ) {
137143 addVariableToString ( envVarKey , envVarValue ) ;
138144 }
139145 } ) ;
140146
141147 await fs . promises . writeFile ( envVarFilePath , variableString ) ;
142148}
143149
144- function getNullableBooleanFromString ( boolString :string ) : boolean {
150+ function getNullableBooleanFromString ( boolString : string ) : boolean {
145151 if ( boolString == null ) return null ;
146152 boolString = boolString . toLowerCase ( ) ;
147153
148- if ( boolString === "true" ) {
154+ if ( boolString === "true" ) {
149155 return true ;
150156 }
151157
152- if ( boolString === "false" ) {
158+ if ( boolString === "false" ) {
153159 return false ;
154160 }
155161
0 commit comments