@@ -5,33 +5,78 @@ import { extractTodosFromDir } from './parser/extractTodosFromDir';
55import { TodoItem } from './parser/types' ;
66
77async function run ( ) : Promise < void > {
8- try {
9- const token = core . getInput ( 'repo-token' , { required : true } ) ;
10- const workspace = process . env . GITHUB_WORKSPACE || '.' ;
8+ try {
9+ const token = core . getInput ( 'repo-token' , { required : true } ) ;
10+ const workspace = process . env . GITHUB_WORKSPACE || '.' ;
11+
12+ const todos : TodoItem [ ] = extractTodosFromDir ( workspace ) ;
13+ const octokit = github . getOctokit ( token ) ;
14+ const { owner, repo } = github . context . repo ;
15+
16+ core . info ( `🔍 Found ${ todos . length } TODOs` ) ;
17+
18+ // Limit to avoid triggering GitHub's rate limiter
19+ const MAX_ISSUES = 5 ;
20+
21+ const todosToCreate = todos
22+ . filter ( todo => todo . text && todo . text . length > 5 )
23+ . slice ( 0 , MAX_ISSUES ) ;
24+
25+ for ( const todo of todosToCreate ) {
26+ const title = `[${ todo . tag } ] ${ todo . text } ` ;
27+ const body = `Found in \`${ todo . file } :${ todo . line } \`\n\n\`\`\`\n${ todo . text } \n\`\`\`` ;
28+
29+ try {
30+ await octokit . rest . issues . create ( {
31+ owner,
32+ repo,
33+ title,
34+ body
35+ } ) ;
36+
37+ core . info ( `✅ Created issue: ${ title } ` ) ;
38+ } catch ( err : any ) {
39+ core . warning ( `⚠️ Failed to create issue for: ${ title } — ${ err . message } ` ) ;
40+ }
41+ }
42+
43+ } catch ( error : any ) {
44+ core . setFailed ( `Action failed: ${ error . message } ` ) ;
45+ }
46+ }
47+
48+ run ( ) ;
1149
12- const todos : TodoItem [ ] = extractTodosFromDir ( workspace ) ;
13- const octokit = github . getOctokit ( token ) ;
14- const { owner, repo } = github . context . repo ;
1550
16- core . info ( `🔍 Found ${ todos . length } TODOs` ) ;
1751
18- for ( const todo of todos ) {
19- const title = `[${ todo . tag } ] ${ todo . text } ` ;
20- const body = `Found in \`${ todo . file } :${ todo . line } \`\n\n\`\`\`\n${ todo . text } \n\`\`\`` ;
52+ // async function run(): Promise<void> {
53+ // try {
54+ // const token = core.getInput('repo-token', { required: true });
55+ // const workspace = process.env.GITHUB_WORKSPACE || '.';
2156
22- await octokit . rest . issues . create ( {
23- owner,
24- repo,
25- title,
26- body
27- } ) ;
57+ // const todos: TodoItem[] = extractTodosFromDir(workspace);
58+ // const octokit = github.getOctokit(token);
59+ // const { owner, repo } = github.context.repo;
2860
29- core . info ( `✅ Created issue: ${ title } ` ) ;
30- }
61+ // core.info(`🔍 Found ${todos.length} TODOs`);
3162
32- } catch ( error : any ) {
33- core . setFailed ( `Action failed: ${ error . message } ` ) ;
34- }
35- }
63+ // for (const todo of todos) {
64+ // const title = `[${todo.tag}] ${todo.text}`;
65+ // const body = `Found in \`${todo.file}:${todo.line}\`\n\n\`\`\`\n${todo.text}\n\`\`\``;
66+
67+ // await octokit.rest.issues.create({
68+ // owner,
69+ // repo,
70+ // title,
71+ // body
72+ // });
73+
74+ // core.info(`✅ Created issue: ${title}`);
75+ // }
76+
77+ // } catch (error: any) {
78+ // core.setFailed(`Action failed: ${error.message}`);
79+ // }
80+ // }
3681
37- run ( ) ;
82+ // run();
0 commit comments