adding slack notification to channel if it loops for more than 5 mins #1086
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
jobs: | |
CI: | |
name: "CI" | |
runs-on: Windows | |
timeout-minutes: 60 | |
steps: | |
- name: Check out the GM-TestFramework repo | |
uses: actions/checkout@v4 | |
with: | |
path: GM-TF | |
# - name: Wait for 10 Minutes | |
# run: Start-Sleep -Seconds 300 | |
# shell: pwsh | |
- run: .\setup.bat | |
working-directory: GM-TF | |
shell: cmd | |
- name: Testing on PR | |
run: | | |
$startTime = Get-Date | |
$timeoutMinutes = 5 | |
$maxTime = $startTime.AddMinutes($timeoutMinutes) | |
Write-Host "Starting build..." | |
cmd /c "${{ github.workspace}}\GM-TF\run_ci.bat C:\GM-TestFramework\configs\${{ github.event.inputs.CONFIG_FILE }} ${{ github.event.inputs.RSS_Feed }} ${{ github.event.inputs.EXTRA_PARAMS }}" | |
# Monitor process for looping | |
while ($true) { | |
if ((Get-Date) -gt $maxTime) { | |
# If looping exceeds 5 minutes, send a Slack notification and exit | |
$slackPayload = @{ | |
channel = "C07AMRFCC0P" | |
text = "Build is stuck in a loop for more than 5 minutes. Exiting process." | |
} | ConvertTo-Json -Depth 10 | |
Invoke-RestMethod -Uri "${{ secrets.SLACK_WEBHOOK_URL }}" -Method POST -ContentType "application/json" -Body $slackPayload | |
throw "Build exceeded the 5-minute timeout and was terminated." | |
} | |
Start-Sleep -Seconds 10 # Check every 10 seconds | |
} | |
- name: Upload Results Artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: summary_file | |
path: ${{ github.workspace }}\GM-TF\results | |