fix: add logic.js and api.js + fix require path resolution (#28) - #28
Conversation
|
🤖 [AI-generated] Hey Romuald Lemesle (@RomuDeuxfois)! 👋 Thanks a lot for opening PR #28 — the Problem / Fix write-up is genuinely excellent (the exact error, both root causes, and the three concrete changes are super clear). Really appreciate it! 🙏 Just one small, optional suggestion to help reviewers and keep things tidy — I haven't changed anything in your description:
No rush at all — thanks again for keeping the CI tooling healthy! 🚀 |
There was a problem hiding this comment.
Pull request overview
This PR fixes the move-closed-issue-to-milestone composite action by ensuring its helper modules are present and by making require() resolve relative to the action’s own checkout path (via github.action_path / ACTION_PATH) rather than the caller repository workspace.
Changes:
- Add/restore the action’s helper modules (
logic.js,api.js) used byactions/github-script. - Update
action.ymlto require helpers viaprocess.env.ACTION_PATH. - Extend decision logic to skip moving issues already in the target milestone.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| actions/move-closed-issue-to-milestone/action.yml | Exposes github.action_path as ACTION_PATH and requires helper modules using that path; passes milestone into decision input. |
| actions/move-closed-issue-to-milestone/logic.js | Implements decide() to determine skip/move based on labels and current milestone. |
| actions/move-closed-issue-to-milestone/api.js | Adds Octokit wrappers to fetch issues, find/create milestones, and set an issue’s milestone. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function decide({ sourceLabels, targetMilestone, issue }) { | ||
| if (!issue) { | ||
| return { action: 'skip', reason: 'No issue provided' }; | ||
| } | ||
| const issueLabels = issue.labels || []; | ||
| const hasMatchingLabel = issueLabels.some(label => sourceLabels.includes(label)); | ||
| const issueLabels = (issue.labels || []).map((l) => l.name ?? l); | ||
|
|
||
| const hasMatchingLabel = sourceLabels.some((label) => issueLabels.includes(label)); | ||
|
|
| * @param {string[]} params.sourceLabels - Labels that trigger the move | ||
| * @param {string} params.targetMilestone - Name of the target milestone | ||
| * @param {object} params.issue - Issue object { number, labels[] } | ||
| * @returns {{ action: 'skip'|'move', issueNumber?: number, reason?: string }} |
Problem
The
move-closed-issue-to-milestoneaction was failing with:Two root causes:
logic.jsandapi.jswere never committed — the action referenced them but they didn't exist in the repo.require()paths were workspace-relative —actions/github-scriptresolvesrequire()relative to the caller's workspace, not the action's own directory. So./actions/move-closed-issue-to-milestone/logic.jsresolved to/home/runner/work/openaev/openaev/actions/...instead of the action checkout path.Fix
logic.js—decide()function (label matching + milestone check)api.js—getIssue(),findOrCreateMilestone(),setIssueMilestone()wrappersaction.yml: exposegithub.action_pathasACTION_PATHenv var and useprocess.env.ACTION_PATH + '/logic.js'inrequire()— this always resolves to the action's own directory regardless of the calling repo