Update action.yml and check.go to clarify PR comment behavior

Enhance the description for the 'comment_pr' input in action.yml to specify that it defaults to true when GITHUB_TOKEN is present. In check.go, update the logic to explicitly disable PR commenting only when the input is set to "false", improving clarity on the commenting behavior during PR checks.
This commit is contained in:
Luke Hagar
2025-11-14 20:36:58 +00:00
parent bd21420b3e
commit eb6a7a4366
2 changed files with 7 additions and 4 deletions

View File

@@ -32,7 +32,7 @@ inputs:
description: "Fail the job if any links fail"
required: false
comment_pr:
description: "If running on a PR, post a comment with the report"
description: "If running on a PR, post a comment with the report. Default: true (enabled when GITHUB_TOKEN is present)"
required: false
step_summary:
description: "Append the report to the GitHub Step Summary"

View File

@@ -317,11 +317,14 @@ func init() {
}
// If running on a PR, post or update the comment(s), chunking as needed
// Check if PR commenting is enabled (default to true if not set)
commentPR := true
// PR comments are enabled by default when token is present
// Only disable if explicitly set to "false"
commentPR := true // Default: enabled
if val := os.Getenv("INPUT_COMMENT_PR"); val != "" {
commentPR = strings.EqualFold(val, "true")
// Explicitly check for "false" to disable, everything else enables
commentPR = !strings.EqualFold(strings.TrimSpace(val), "false")
}
// Only post comments if: GitHub PR detected, commenting enabled, and report exists
if ghOK && commentPR && strings.TrimSpace(finalMDPath) != "" {
b, rerr := os.ReadFile(finalMDPath)
if rerr != nil {