Skip to content

Commit a43ee6b

Browse files
fix: divide the workflow into 3 seperate jobs
1 parent a50138f commit a43ee6b

1 file changed

Lines changed: 39 additions & 10 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
else
9999
echo "Resource group already exists."
100100
fi
101+
echo "RESOURCE_GROUP_NAME=${{ env.RESOURCE_GROUP_NAME }}" >> $GITHUB_OUTPUT
101102
102103
- name: Generate Unique Solution Prefix
103104
id: generate_solution_prefix
@@ -137,7 +138,7 @@ jobs:
137138
BICEP_OUTPUT=$(az deployment group show --name ${{ env.SOLUTION_PREFIX }}-deployment --resource-group ${{ env.RESOURCE_GROUP_NAME }} --query "properties.outputs" -o json)
138139
echo "Extracting deployment output..."
139140
WEBAPP_URL=$(echo $BICEP_OUTPUT | jq -r '.weB_APP_URL.value')
140-
echo "WEBAPP_URL=$WEBAPP_URL" >> $GITHUB_ENV
141+
echo "WEBAPP_URL=$WEBAPP_URL" >> $GITHUB_OUTPUT
141142
STORAGE_ACCOUNT_NAME=$(echo $BICEP_OUTPUT | jq -r '.storagE_ACCOUNT_NAME.value')
142143
echo "STORAGE_ACCOUNT_NAME=$STORAGE_ACCOUNT_NAME" >> $GITHUB_ENV
143144
STORAGE_CONTAINER_NAME=$(echo $BICEP_OUTPUT | jq -r '.storagE_CONTAINER_NAME.value')
@@ -163,16 +164,38 @@ jobs:
163164
"${{ env.KEY_VAULT_NAME }}" \
164165
"${{ secrets.AZURE_CLIENT_ID }}"
165166
166-
- name: Call Test Automation Workflow
167-
if: success()
168-
id: call_test_automation
169-
uses: ./.github/workflows/gp-test-automation.yml
170-
with:
171-
DOCGEN_URL: ${{ env.WEBAPP_URL }}
167+
- name: Logout from Azure
168+
if: always()
169+
run: |
170+
az logout
171+
echo "Logged out from Azure."
172+
173+
174+
gp-tests:
175+
needs: deploy
176+
uses: ./.github/workflows/gp-test-automation.yml
177+
with:
178+
DOCGEN_URL: ${{ needs.deploy.outputs.WEBAPP_URL }}
179+
180+
cleanup-deployment:
181+
if: always() && needs.deploy.outputs.RESOURCE_GROUP_NAME != ''
182+
needs: [deploy, gp-tests]
183+
runs-on: ubuntu-latest
184+
env:
185+
RESOURCE_GROUP_NAME: ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}
186+
steps:
187+
- name: Setup Azure CLI
188+
run: |
189+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
190+
az --version # Verify installation
172191
192+
- name: Login to Azure
193+
run: |
194+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
195+
az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
173196
174197
- name: Extract AI Services and Key Vault Names
175-
if: always() && steps.check_create_rg.outcome == 'success'
198+
if: always()
176199
run: |
177200
echo "Fetching AI Services and Key Vault names before deletion..."
178201
@@ -332,17 +355,23 @@ jobs:
332355
333356
334357
- name: Send Notification on Failure
335-
if: failure()
358+
if: failure() || needs.deploy.result == 'failure'
336359
run: |
337360
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
338361
339362
EMAIL_BODY=$(cat <<EOF
340363
{
341-
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> ${RUN_URL}<br> ${OUTPUT}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
364+
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen Deployment Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> ${RUN_URL}<br> ${OUTPUT}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
342365
}
343366
EOF
344367
)
345368
346369
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
347370
-H "Content-Type: application/json" \
348371
-d "$EMAIL_BODY" || echo "Failed to send notification"
372+
373+
- name: Logout from Azure
374+
if: always()
375+
run: |
376+
az logout
377+
echo "Logged out from Azure."

0 commit comments

Comments
 (0)