From 3b7e6a11a6d3d7ec362de020e32c2e90d81b5ecf Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Fri, 23 Jul 2021 16:36:25 +0930 Subject: [PATCH] Add property for setting SHA - Allows overriding the 'auto-detection' logic Fixes #29 --- action.ps1 | 8 +++++++- action.yml | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/action.ps1 b/action.ps1 index 4753926..9deb0ca 100644 --- a/action.ps1 +++ b/action.ps1 @@ -35,6 +35,7 @@ $inputs = @{ trx_xsl_path = Get-ActionInput trx_xsl_path extra_test_parameters = Get-ActionInput extra_test_parameters fail_build_on_failed_tests = Get-ActionInput fail_build_on_failed_tests + sha = Get-ActionInput sha } $tmpDir = [System.IO.Path]::Combine($PWD, '_TMP') @@ -95,7 +96,11 @@ function Publish-ToCheckRun { Write-ActionInfo "Resolving REF" $ref = $ctx.Sha - if ($ctx.EventName -eq 'pull_request') { + + if ($inputs.sha) { + Write-ActionInfo "Resolving as input sha" + $ref = $inputs.sha + } elseif ($ctx.EventName -eq 'pull_request') { Write-ActionInfo "Resolving PR REF" $ref = $ctx.Payload.pull_request.head.sha if (-not $ref) { @@ -103,6 +108,7 @@ function Publish-ToCheckRun { $ref = $ctx.Payload.after } } + if (-not $ref) { Write-ActionError "Failed to resolve REF" exit 1 diff --git a/action.yml b/action.yml index 8330229..b430fe6 100644 --- a/action.yml +++ b/action.yml @@ -144,7 +144,11 @@ inputs: fail_build_on_failed_tests: description: | - If set to true, the build will fail if at least one test fails + If set to true, the build will fail if at least one test fails + + sha: + description: The commit that the report check will be associated with. This is auto-detected by default. + required: false ## Here you describe your *formal* outputs.