Export main function instead of auto-executing in GitHub Actions scripts#7465
Merged
Export main function instead of auto-executing in GitHub Actions scripts#7465
Conversation
Fixed 10 JavaScript files to export main function instead of automatically invoking it:
- actions/setup/js: checkout_pr_branch.cjs, add_copilot_reviewer.cjs, assign_issue.cjs, create_agent_task.cjs, push_repo_memory.cjs
- pkg/workflow/js: checkout_pr_branch.cjs, add_copilot_reviewer.cjs, assign_issue.cjs, check_workflow_timestamp.cjs, create_agent_task.cjs, push_repo_memory.cjs
Changed pattern from:
main().catch(error => { core.setFailed(...); });
To:
module.exports = { main };
This allows GitHub Actions workflows to import and call main() explicitly.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated tests to explicitly call main() for files that now export instead of auto-execute: - create_agent_task.test.cjs: Updated runScript to call main() - add_copilot_reviewer.test.cjs: Added runScript helper and updated all tests Tests for assign_issue and check_workflow_timestamp already used eval with explicit main() calls, so they work correctly. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix JavaScript file to export main and remove conditional invocation
Export main function instead of auto-executing in GitHub Actions scripts
Dec 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Several JavaScript files used in GitHub Actions workflows were auto-executing
main()on require, causing execution before workflows were ready. Workflows expect to import and explicitly callmain().Changes
Pattern changed from:
To:
Affected files (10):
checkout_pr_branch.cjsadd_copilot_reviewer.cjsassign_issue.cjscheck_workflow_timestamp.cjscreate_agent_task.cjspush_repo_memory.cjs(Updated in both
pkg/workflow/js/source andactions/setup/js/compiled locations)Test files updated (2):
create_agent_task.test.cjs- UpdatedrunScript()to callmain()explicitlyadd_copilot_reviewer.test.cjs- AddedrunScript()helper for explicitmain()invocationNot Changed
MCP server files (
safe_inputs_mcp_server.cjs,safe_outputs_mcp_server.cjs) retainif (require.main === module)pattern as they're executed standalone vianode script.cjs, not imported.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.