From 222b3db615a2da2521657c823742310e449dc00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Ord=C3=A1s?= <3125580+davorpa@users.noreply.github.com> Date: Wed, 21 Sep 2022 19:05:05 +0200 Subject: [PATCH] fix: crash on empty changed files (#7059) If a PR hasn't any changed file, the GitHub report fails with an exception Simulated evidence: https://github.com/davorpa/free-programming-books/actions/runs/3007631429 Fixed: https://github.com/davorpa/free-programming-books/actions/runs/3007755638 --- .../actions/awesomebot-gh-summary-action/action.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/actions/awesomebot-gh-summary-action/action.yml b/.github/actions/awesomebot-gh-summary-action/action.yml index 629ecd3ce..b1f340c68 100644 --- a/.github/actions/awesomebot-gh-summary-action/action.yml +++ b/.github/actions/awesomebot-gh-summary-action/action.yml @@ -60,8 +60,18 @@ runs: # Loop ForEach files $env:INPUT_FILES -split $env:INPUT_SEPARATOR | ForEach { $file = $_ + if ($file -match "\s+" ) { + continue # is empty string + } $abr_file = $env:INPUT_AB_ROOT + "/ab-results-" + ($file -replace "[/\\]","-") + "-markdown-table.json" - $json = Get-Content $abr_file | ConvertFrom-Json + + try { + $json = Get-Content $abr_file | ConvertFrom-Json + } catch { + $message = $_ + echo "::error ::$message" # Notify as GitHub Actions annotation + continue # Don't crash!! + } $text += "`n`n" if ("true" -eq $json.error) {