Find the TODO comment in the pull request diff.
name: Find TODOs in pull requests
on:
pull_request:
jobs:
find-todos:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: indigo-san/todo-comments-in-pr@vx.y.z
id: todos
- name: Generate a summary of the tasks
uses: actions/github-script@v7
id: summary
with:
result-encoding: string
script: |
const tasks = JSON.parse(String.raw`${{ steps.todos.outputs.tasks }}`);
let body = tasks.map(task => `https://github.com/${{ github.repository }}/blob/${{ github.sha }}/${task.fileName}#L${task.startLine}-L${task.endLine}`).join('\n');
if (tasks.length > 0) {
body = `The following TODO comments were found:\n\n${body}`;
} else {
body = 'No TODO comments were found.';
}
return body;
- name: Comment on the pull request
uses: marocchino/sticky-pull-request-comment@v2
with:
header: todo-cooments
recreate: true
message: |
${{ steps.summary.outputs.result }}
Optional The path to the file to search for TODOs. Need to specify a Json
array.
(default: ["*.cs","*.js","*.jsx","*.ts","*.tsx","*.css","*.scss","*.sass"]
)
Optional The commit to compare the current commit to.
(default: ${{ github.event.pull_request.base.ref }}
)
Optional The regex pattern to match single-line comments.
(default: \/\/.*
)
Optional The regex pattern to match the start of a multi-line comment.
(default: \/\*
)
Optional The regex pattern to match the end of a multi-line comment.
(default: \*\/
)
Optional The regex pattern to match the keywords.
(default: TODO
)
The list of tasks found in the diff.
[
{
"startLine": 1,
"endLine": 1,
"content": "// TODO: test",
"fileName": "path/to/file"
}
]
The number of tasks found in the diff.