Add triggering issue/PR/discussion reference to safe output footers #1734
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Safe output footers (in issues, comments, and PR review comments) currently only show the workflow name and action run link, but don't reference the triggering issue, pull request, or discussion that caused the workflow to run. This makes it harder to trace the context of AI-generated content.
Previous footer:
> AI generated by [My Workflow](https://github.com/owner/repo/actions/runs/12345)Solution
Enhanced the
generateFooter()function in all three safe output scripts to automatically include a reference to the triggering issue, PR, or discussion when available, using GitHub's reference syntax.New footer (when triggered by issue #42):
> AI generated by [My Workflow](https://github.com/owner/repo/actions/runs/12345) for #42New footer (when triggered by discussion #789):
> AI generated by [My Workflow](https://github.com/owner/repo/actions/runs/12345) for discussion #789Implementation Details
The implementation extracts triggering context from
context.payloadand correctly distinguishes between:context.payload.issue.number(excluding PRs)context.payload.pull_request.numberor detects PRs masquerading as issues viacontext.payload.issue.pull_requestcontext.payload.discussion.numberWhen no triggering context is available (e.g., scheduled workflows, manual triggers), the footer remains unchanged to avoid adding incorrect references.
Files Changed
Source files:
pkg/workflow/js/create_issue.cjs- Updated footer generation for issue creationpkg/workflow/js/add_comment.cjs- Updated footer generation for commentspkg/workflow/js/create_pr_review_comment.cjs- Updated footer generation for PR review commentspkg/workflow/js/create_issue.test.cjs- Added 3 new testspkg/workflow/js/add_comment.test.cjs- Added 2 new testspkg/workflow/js/create_pr_review_comment.test.cjs- Added 1 new testGenerated files:
.lock.ymlfiles automatically recompiled with new footer functionalityTesting
Impact
This enhancement improves traceability of AI-generated content by providing a clear, clickable reference back to the triggering event, making it easier for users to understand the context in which the content was created.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.