diff --git a/.github/workflows/run-scrpit.yaml b/.github/workflows/run-scrpit.yaml new file mode 100644 index 0000000..2819aed --- /dev/null +++ b/.github/workflows/run-scrpit.yaml @@ -0,0 +1,24 @@ +name: Make Shell Scripts Executable on Merge to Main + +on: + push: + +jobs: + make-executable: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Make all .sh files executable + run: | + find . -type f -name "*.sh" -exec chmod +x {} \; + - name: Commit and push permission changes + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + git diff --cached --quiet || git commit -m "Set execute permission on .sh files" + git push + + \ No newline at end of file diff --git a/README.md b/README.md index 33ee146..4c5016b 100644 --- a/README.md +++ b/README.md @@ -471,7 +471,6 @@ The template also includes dependent resources: ### Azure Container Apps - If your ACA does not boot up, it is possible that your deployment has failed. This could be due to quota constraints, permission issues, or resource availability. Check failures in the deployment and container app logs in the Azure Portal. - - Console traces in ACA can be found in the Azure Portal, but they may be unreliable. Use Python’s logging with INFO level, and adjust Azure HTTP logging to WARNING. - Once your ACA is deployed, utilize the browser debugger (F12) and clear cache (CTRL+SHIFT+R). This can help debug the frontend for better traceability. diff --git a/scripts/setup_credential.ps1 b/scripts/setup_credential.ps1 index 16faa3b..39c5db1 100644 --- a/scripts/setup_credential.ps1 +++ b/scripts/setup_credential.ps1 @@ -1,3 +1,23 @@ +# Check Azure login status +$azAccount = az account show 2>$null + +if (-not $azAccount) { + + Write-Host "πŸ” Not logged in to Azure. Attempting to login..." -ForegroundColor Yellow + $azureTenantId = azd env get-value AZURE_TENANT_ID + az login --tenant $azureTenantId | Out-Null + + if ($LASTEXITCODE -ne 0) { + Write-Host "❌ Azure login failed. Exiting script." -ForegroundColor Red + exit 1 + } + + Write-Host "βœ… Logged in to Azure successfully." -ForegroundColor Green +} else { + $accountInfo = $azAccount | ConvertFrom-Json + Write-Host "βœ… Already logged in as: $($accountInfo.user.name)" -ForegroundColor Green +} + # Prompt for username with validation do { $username = Read-Host -Prompt 'πŸ‘€ Create a new username for the web app (no spaces, at least 1 character)' diff --git a/scripts/setup_credential.sh b/scripts/setup_credential.sh index f1313d6..53816d1 100644 --- a/scripts/setup_credential.sh +++ b/scripts/setup_credential.sh @@ -1,5 +1,29 @@ #!/bin/bash +set -e + +# Check if already logged in +if ! az account show &>/dev/null; then + echo -e "πŸ” Not logged in to Azure. Attempting to login..." + + azureTenantId=$(azd env get-value AZURE_TENANT_ID) + if [[ -z "$azureTenantId" ]]; then + echo "❌ AZURE_TENANT_ID is not set in the environment. Exiting." + exit 1 + fi + + az login --tenant "$azureTenantId" > /dev/null + if [[ $? -ne 0 ]]; then + echo "❌ Azure login failed. Exiting script." + exit 1 + fi + + echo "βœ… Logged in to Azure successfully." +else + user=$(az account show --query user.name -o tsv) + echo "βœ… Already logged in as: $user" +fi + templateValidationMode="${TEMPLATE_VALIDATION_MODE}" if [[ "$templateValidationMode" == true ]]; then