|
29 | 29 | - name: Checkout code
|
30 | 30 | uses: actions/checkout@v4
|
31 | 31 |
|
| 32 | + # Run Quota Check Script |
| 33 | + - name: Run Quota Check |
| 34 | + id: quota-check |
| 35 | + run: | |
| 36 | + export AZURE_CLIENT_ID=${{ secrets.AZURE_CLIENT_ID }} |
| 37 | + export AZURE_TENANT_ID=${{ secrets.AZURE_TENANT_ID }} |
| 38 | + export AZURE_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }} |
| 39 | + export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}" |
| 40 | + export GPT_MIN_CAPACITY="30" |
| 41 | + export TEXT_EMBEDDING_MIN_CAPACITY="30" |
| 42 | + export AZURE_REGIONS="${{ vars.AZURE_REGIONS }}" |
| 43 | +
|
| 44 | + chmod +x scripts/checkquota.sh |
| 45 | + if ! scripts/checkquota.sh; then |
| 46 | + # If quota check fails due to insufficient quota, set the flag |
| 47 | + if grep -q "No region with sufficient quota found" scripts/checkquota.sh; then |
| 48 | + echo "QUOTA_FAILED=true" >> $GITHUB_ENV |
| 49 | + fi |
| 50 | + exit 1 # Fail the pipeline if any other failure occurs |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Send Notification on Quota Failure |
| 54 | + if: env.QUOTA_FAILED == 'true' |
| 55 | + run: | |
| 56 | + RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 57 | + EMAIL_BODY=$(cat <<EOF |
| 58 | + { |
| 59 | + "body": "<p>Dear Team,</p><p>The quota check has failed, and the pipeline cannot proceed.</p><p><strong>Build URL:</strong> ${RUN_URL}</p><p>Please take necessary action.</p><p>Best regards,<br>Your Automation Team</p>" |
| 60 | + } |
| 61 | + EOF |
| 62 | + ) |
| 63 | +
|
| 64 | + curl -X POST "${{ secrets.LOGIC_APP_URL }}" \ |
| 65 | + -H "Content-Type: application/json" \ |
| 66 | + -d "$EMAIL_BODY" || echo "Failed to send notification" |
| 67 | +
|
| 68 | + - name: Fail Pipeline if Quota Check Fails |
| 69 | + if: env.QUOTA_FAILED == 'true' |
| 70 | + run: exit 1 |
| 71 | + |
| 72 | + # The pipeline stops here if quota check fails! |
| 73 | + |
| 74 | + - name: Set Deployment Region |
| 75 | + run: | |
| 76 | + echo "Selected Region: $VALID_REGION" |
| 77 | + echo "AZURE_LOCATION=$VALID_REGION" >> $GITHUB_ENV |
| 78 | +
|
32 | 79 | - name: Login to GitHub Container Registry
|
33 | 80 | uses: docker/login-action@v3
|
34 | 81 | with:
|
|
51 | 98 | uses: devcontainers/[email protected]
|
52 | 99 | env:
|
53 | 100 | AZURE_ENV_NAME: ${{ github.run_id }}
|
54 |
| - AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} |
| 101 | + AZURE_LOCATION: ${{ env.AZURE_LOCATION }} |
55 | 102 | with:
|
56 | 103 | imageName: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
|
57 | 104 | cacheFrom: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
|
|
0 commit comments