Skip to content

ci: skip PR comment step when workflow_run has no pull request#886

Open
InukaWijerathna wants to merge 1 commit into
nodejs:mainfrom
InukaWijerathna:fix-leave-comment-workflow
Open

ci: skip PR comment step when workflow_run has no pull request#886
InukaWijerathna wants to merge 1 commit into
nodejs:mainfrom
InukaWijerathna:fix-leave-comment-workflow

Conversation

@InukaWijerathna

Copy link
Copy Markdown

Summary

leave-comment.yml runs after Generate and Compare Docs completes via workflow_run. That workflow triggers on both push (to main) and pull_request, but leave-comment.yml unconditionally assumes there's a PR to comment on.

For push-triggered runs (e.g. after a merge to main), github.event.workflow_run.pull_requests[0] is undefined, so the Add Comment to PR step fails with:

No issue/pull request in input neither in current context.

Example failing run: https://github.com/nodejs/doc-kit/actions/runs/28747289633/job/85240250539 (triggered by a push to main, not a PR).

Fix

Guard the aggregate job with if: github.event.workflow_run.event == 'pull_request', so it only runs (and only attempts to comment) when the triggering workflow run actually originated from a pull request.

Test plan

  • Confirmed via the workflow run logs that the failing run's triggering event was a push to main, not a PR, matching this fix's guard condition
  • YAML structure/indentation verified by hand and formatted by the repo's own prettier pre-commit hook (*.yml files are covered by .lintstagedrc.json)
  • Not verifiable locally end-to-end since workflow_run behavior only manifests on GitHub's runners, but the fix directly targets the exact condition (workflow_run.event) that caused the observed failure

leave-comment.yml runs after "Generate and Compare Docs", which
triggers on both push (to main) and pull_request. Push-triggered runs
have no associated PR, so github.event.workflow_run.pull_requests[0]
is undefined and the comment step fails with "No issue/pull request
in input neither in current context."

Guard the job so it only runs when the triggering workflow_run was
itself started by a pull_request event.

Refs: https://github.com/nodejs/doc-kit/actions/runs/28747289633/job/85240250539
@InukaWijerathna InukaWijerathna requested a review from a team as a code owner July 5, 2026 18:03
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Jul 5, 2026 6:05pm

Request Review

@cursor

cursor Bot commented Jul 5, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
CI-only conditional on workflow_run event; no application or security logic changes.

Overview
Fixes failing leave-comment runs when Generate and Compare Docs completes after a push to main (e.g. post-merge), where there is no PR to comment on.

The aggregate job now runs only when github.event.workflow_run.event == 'pull_request', so artifact download and the PR comment step are skipped for push-triggered workflow_run events instead of erroring with missing PR context.

Reviewed by Cursor Bugbot for commit 47649c0. Bugbot is set up for automated code reviews on this repo. Configure here.

# Only pull_request-triggered runs have a PR to comment on; runs triggered
# by a plain push to main (e.g. after a merge) have none, and attempting
# to comment in that case fails with "No issue/pull request in input".
if: github.event.workflow_run.event == 'pull_request'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if: github.event.workflow_run.event == 'pull_request'
if: github.event.workflow_run.pull_requests[0].number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants