Skip to content

add_comment.cjs: invocation.workflowRepo resolved but discarded when building footer run URL #30872

@yskopets

Description

@yskopets

Bug Report

File: actions/setup/js/add_comment.cjs

Summary

add_comment.cjs calls resolveInvocationContext(rawContext) (via resolveEffectiveEventContext, line ~53) to obtain an invocation object that includes invocation.workflowRepo. However, when building the footer run URL further down, it uses context.repo directly instead of invocation.workflowRepo:

// line ~580
const runUrl = buildWorkflowRunUrl(context, context.repo);

The invocation.workflowRepo value is only used for eventName and eventPayload inside resolveEffectiveEventContext — it is never propagated to buildWorkflowRunUrl.

Impact

In repository_dispatch-triggered workflows that target a different repository than the one hosting the workflow, context.repo is typically patched to the target repo so that safe-output actions (comments, labels, etc.) go to the right place. resolveInvocationContext correctly resolves workflowRepo as the original workflow repo in this scenario, but since add_comment.cjs ignores it and uses the patched context.repo instead, the {run_url} in comment footers points to the target repo rather than the workflow repo where the run actually lives.

The existing workaround for the activation comment (add_workflow_run_comment.cjs) is a runtime sed patch:

sed -i 's/buildWorkflowRunUrl(context, context\.repo)/buildWorkflowRunUrl(context, context.workflowRepo ?? context.repo)/g' add_workflow_run_comment.cjs

The same patch would be needed for add_comment.cjs, but the root cause should be fixed in the source.

Expected behavior

buildWorkflowRunUrl should receive invocation.workflowRepo (already resolved) instead of context.repo:

// Suggested fix in add_comment.cjs
const invocation = resolveInvocationContext(rawContext); // already called inside resolveEffectiveEventContext
const runUrl = buildWorkflowRunUrl(context, invocation.workflowRepo);

Or: expose workflowRepo from resolveEffectiveEventContext so callers don't need to call resolveInvocationContext twice.

Context

  • add_workflow_run_comment.cjs already does this correctly — it calls resolveInvocationContext(context).workflowRepo and passes the result to buildWorkflowRunUrl. add_comment.cjs should follow the same pattern.
  • resolveInvocationContext handles all three invocation styles (native, workflow_dispatch, repository_dispatch) and returns the correct workflowRepo in each case.

Reported by Claude Sonnet 4.6 while investigating footer URL regressions in a repository_dispatch-based workflow wrapper.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions