Skip to content

adding slack notification to channel if it loops for more than 5 mins #1092

adding slack notification to channel if it loops for more than 5 mins

adding slack notification to channel if it loops for more than 5 mins #1092

Workflow file for this run

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: |
@echo on
setlocal enabledelayedexpansion
set "startTime=%time%"
set "timeoutMinutes=5"
echo Starting build...
start "" /b run_ci.bat C:\GM-TestFramework\configs\${{ github.event.inputs.CONFIG_FILE }} ${{ github.event.inputs.RSS_Feed }} ${{ github.event.inputs.EXTRA_PARAMS }}
set /a "timeoutSeconds=timeoutMinutes*60"
set "elapsedTime=0"
:loop
timeout /t 10 >nul
set /a "elapsedTime+=10"
if !elapsedTime! geq !timeoutSeconds! (
echo Build is stuck in a loop for more than %timeoutMinutes% minutes. Exiting process.
powershell -Command "Invoke-RestMethod -Uri '%SLACK_WEBHOOK_URL%' -Method POST -ContentType 'application/json' -Body '{\"text\":\"Build is stuck in a loop for more than %timeoutMinutes% minutes. Exiting process.\"}'"
taskkill /im run_ci.bat /f
exit /b 1
)
tasklist /fi "imagename eq run_ci.bat" | find /i "run_ci.bat" >nul
if errorlevel 1 (
echo Build completed successfully.
exit /b 0
)
goto :loop
shell: cmd
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
working-directory: GM-TF
- name: Upload Results Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: summary_file
path: ${{ github.workspace }}\GM-TF\results