Skip to content

Fix lock/unlock issue scripts to support both require() and inline modes#7444

Merged
pelikhan merged 5 commits intomainfrom
copilot/fix-lock-unlock-scripts
Dec 23, 2025
Merged

Fix lock/unlock issue scripts to support both require() and inline modes#7444
pelikhan merged 5 commits intomainfrom
copilot/fix-lock-unlock-scripts

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

The lock-issue and unlock-issue scripts needed to support two execution modes: require() mode (when used with setup action) and inline mode (when bundled and embedded in YAML).

Changes

Scripts (lock-issue.cjs, unlock-issue.cjs):

  • Added module.exports = { main } for require() compatibility
  • Scripts only export the main function without auto-execution
  • Importer (require() caller) is responsible for calling await main()

Compiler (compiler_activation_jobs.go):

  • Bundle lock-issue script before inlining using BundleJavaScriptWithMode()
  • Bundler strips module.exports via removeExports() for inline mode
  • Compiler adds await main(); after bundling for inline mode execution

Execution Modes

Require mode (setup action - primary):

const { main } = require('/tmp/gh-aw/actions/lock-issue.cjs');
await main(); // Importer calls main

Inline mode (direct YAML embedding - fallback):

script: |
  // Bundled script with module.exports removed
  async function main() { /* ... */ }
  await main();  // Compiler adds this

The scripts now correctly support both execution modes. Setup action files only export the main function, allowing the importer to control execution timing.

Original prompt

Fix the inlining of the lock issue, unlock issue scripts to support the require + exported main function scheme.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 23, 2025 21:44
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… main function scheme

- Updated lock-issue.cjs and unlock-issue.cjs to export main function via module.exports
- Added await main() execution at the end for inline mode
- Modified compiler to bundle lock-issue script when inlining (removes module.exports)
- Scripts now work in both require mode (setup action) and inline mode (direct YAML embedding)
- All JavaScript tests pass (17/17)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
module.exports = { main };

// Execute when inlined (not when required)
await main();
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot do not call main, let importer call it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed await main() from lock-issue.cjs. The setup action files now only export the main function - the importer calls it. (commit 75b7509)

module.exports = { main };

// Execute when inlined (not when required)
await main();
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot do not call main, let importer call it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed await main() from unlock-issue.cjs. The setup action files now only export the main function - the importer calls it. (commit 75b7509)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix inlining for lock and unlock scripts for main function support Fix lock/unlock issue scripts to support both require() and inline modes Dec 23, 2025
Copilot AI requested a review from pelikhan December 23, 2025 22:08
The setup action files (actions/setup/js/*.cjs) should only export the main function
via module.exports, not auto-execute. The importer (require() caller) is responsible
for calling await main().

When bundling for inline mode, the compiler now adds await main() after bundling.

Changes:
- Removed await main() from pkg/workflow/js/lock-issue.cjs
- Removed await main() from pkg/workflow/js/unlock-issue.cjs
- Modified compiler to add await main() when bundling for inline mode
- Rebuilt actions with updated scripts (no await main() in setup files)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review December 23, 2025 22:27
@pelikhan pelikhan merged commit ee75219 into main Dec 23, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/fix-lock-unlock-scripts branch December 23, 2025 22:27
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