Github actions gets auto cancelled for "while" operation in powershell

Hi,

I have this requirement where I have to wait for the testresult.txt file to be generated by other process. “testresult.txt” file gets generated in specific directory which my workflow step has to look for. Below step do a wait and poll kind of operation. In every 5 sec, while loop runs and check for the file availability until 40 mins. If file doesn’t found in 40 mins, workflow step will be failed.

To test the code manually, I have followed the same steps as specified in workflow step and it works fine.

However, with github action, workflow gets auto-cancelled after 5 secs. Step doesn’t fail in this scenario, whole job gets cancelled.

Actions step:

      - name: Test Result Verification
        shell: powershell
        run: |
          cd C:\testresult\
          $timer= Get-Date
          while ( -Not( $tr_file_exists ) ) {
            $tr_file_exists=(Test-Path testresult.txt -PathType Leaf)
            Write-Output "Test Result is not available right now"
            Start-Sleep 5
            if(((Get-Date).Subtract($timer)).minutes -ge 40 ) {
              Write-Output "Test didn't complete in-time"
              exit 1
            }
          }
          $test_result=(Get-Content testresult.txt)
          if($test_result.ToUpper().Trim() -ne "PASS" ){
            Write-Output "BVT Test Failed"
            exit 1
          }else{
            Write-Output "BVT Test Passed"
          }