Skip to content

Commit 1f35010

Browse files
committed
Only submit a comment if we have a valid comments URL
1 parent 812927b commit 1f35010

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

entrypoint.ps1

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@ if (($warnings -gt 0) -or ($infos -gt 0)) {
5151
}
5252
Write-Output $comment
5353

54-
# Comment threshold
55-
54+
$ghEvent = Get-Content -Path $env:GITHUB_EVENT_PATH | ConvertFrom-Json
55+
$commentsUrl = $ghEvent.pull_request.comments_url
5656

5757
# Send comment back to PR if any errors were found
58-
if ($env:PSSCRIPTANALYZER_SEND_COMMENT -ne 'false' -and $env:PSSCRIPTANALYZER_SEND_COMMENT -ne 0) {
58+
if ($env:PSSCRIPTANALYZER_SEND_COMMENT -ne 'false' -and $env:PSSCRIPTANALYZER_SEND_COMMENT -ne 0 -and $commentsUrl) {
5959
if ($errors -gt 0) {
60-
$ghEvent = Get-Content -Path $env:GITHUB_EVENT_PATH | ConvertFrom-Json
6160
$params = @{
62-
Uri = $ghEvent.pull_request.'_links'.comments.href
61+
Uri = $commentsUrl
6362
Method = 'Post'
6463
Headers = @{
6564
Authorization = "token $env:GITHUB_TOKEN"

0 commit comments

Comments
 (0)