File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 55 - main # Adjust this to the branch you want to trigger the deployment on
66 - dev
77 - demo
8+ - hb-script-fix
89 schedule :
910 - cron : " 0 10,22 * * *" # Runs at 10:00 AM and 10:00 PM GMT
1011
Original file line number Diff line number Diff line change @@ -102,8 +102,23 @@ function PromptForParameters {
102102 $params = PromptForParameters - email $email
103103$email = $params.email
104104
105+ $script :alreadyLoggedIn = $false
106+
105107function LoginAzure ([string ]$tenantId , [string ]$subscriptionID ) {
106108 Write-Host " Log in to Azure.....`r`n " - ForegroundColor Yellow
109+ if ([string ]::IsNullOrEmpty($tenantId ) -or [string ]::IsNullOrEmpty($subscriptionID )) {
110+ az login
111+ if ($LASTEXITCODE -ne 0 ) {
112+ Write-Host " Failed to log in to Azure. Please check your credentials." - ForegroundColor Red
113+ failureBanner
114+ exit 1
115+ }
116+ else {
117+ Write-Host " Logged in to Azure successfully." - ForegroundColor Green
118+ $script :alreadyLoggedIn = $true
119+ return
120+ }
121+ }
107122 if ($env: CI -eq " true" ){
108123 az login -- service- principal `
109124 -- username $env: AZURE_CLIENT_ID `
@@ -478,13 +493,16 @@ try {
478493
479494 # Map the deployment result to DeploymentResult object from .env file
480495 if ($ResourceGroupName ) {
496+ LoginAzure " " " "
481497 $deploymentResult.MapResultAz ($ResourceGroupName.Trim ())
482498 }
483499 else {
484500 $deploymentResult.MapResultAzd ()
485501 }
486502
487- LoginAzure $deploymentResult.TenantId $deploymentResult.SubscriptionId
503+ if (-not $script :alreadyLoggedIn ) {
504+ LoginAzure $deploymentResult.TenantId $deploymentResult.SubscriptionId
505+ }
488506
489507 # Display the deployment result
490508 DisplayResult($deploymentResult )
You can’t perform that action at this time.
0 commit comments