Use workflow-id markers for close-older-discussions#13914
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the close-older-discussions feature to use workflow-id XML markers for identifying discussions to close, making it consistent with the close-older-issues feature. The changes remove the previous title-prefix and label-based matching logic in favor of searching for discussions containing a gh-aw-workflow-id: <id> marker in their body.
Changes:
- Refactored
searchOlderDiscussions()to search by workflow-id marker instead of title-prefix/labels - Updated all tests to reflect the new workflow-id based approach
- Updated documentation to remove title-prefix/labels requirements and describe the workflow-id marker approach
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| actions/setup/js/close_older_discussions.cjs | Refactored search logic to use workflow-id markers; added comprehensive logging; removed title-prefix and label filtering |
| actions/setup/js/close_older_discussions.test.cjs | Updated tests to use workflow-id parameters; removed tests for title-prefix and label matching |
| docs/src/content/docs/reference/frontmatter-full.md | Updated documentation to describe workflow-id marker-based approach instead of title-prefix/labels |
| docs/src/content/docs/guides/ephemerals.md | Updated guide examples and requirements to reflect workflow-id marker approach |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const workflowIdMarker = getWorkflowIdMarkerContent(workflowId); | ||
| // Escape quotes in workflow ID to prevent query injection | ||
| const escapedMarker = workflowIdMarker.replace(/"/g, '\\"'); | ||
| let searchQuery = `repo:${owner}/${repo} is:open "${escapedMarker}" in:body`; |
There was a problem hiding this comment.
The search query construction is missing the discussion type filter. For consistency with the issues query (which uses is:issue) and to ensure only discussions are returned, the query should include an explicit type filter.
Compare with close_older_issues.cjs:50 which uses:
repo:${owner}/${repo} is:issue is:open "${escapedMarker}" in:body
This query should be:
repo:${owner}/${repo} is:open is:discussion "${escapedMarker}" in:body
or
repo:${owner}/${repo} is:discussion is:open "${escapedMarker}" in:body
Without the is:discussion filter, the GitHub search API might return other entity types, though the GraphQL query's type: DISCUSSION parameter should filter to discussions. However, having consistency in the search query string itself is clearer and follows the pattern used for issues.
| let searchQuery = `repo:${owner}/${repo} is:open "${escapedMarker}" in:body`; | |
| let searchQuery = `repo:${owner}/${repo} is:open is:discussion "${escapedMarker}" in:body`; |
The
close-older-discussionsfeature searched by title-prefix or labels. This was inconsistent withclose-older-issues, which searches by workflow-id XML markers embedded in the body.Changes
close_older_discussions.cjs: Changed search from title-prefix/labels to workflow-id markersearchOlderDiscussions()signature:(github, owner, repo, workflowId, categoryId, excludeNumber)gh-aw-workflow-id: <id>in discussion body using GitHub search APITests: Updated to use workflow-id instead of title-prefix/labels patterns
Documentation: Removed title-prefix/labels requirements and examples
Before/After
Both issues and discussions now use the same marker-based resolution mechanism.
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.