Skip to content

Commit 8e5a5e3

Browse files
author
tyharwood
committed
Add todo workflow
1 parent 414566d commit 8e5a5e3

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# Script to find TODO/FIXME comments and create GitHub issues
4+
# Usage: ./todo_fixme_to_issues.sh <KEYWORD> <LABEL>
5+
# Example: ./todo_fixme_to_issues.sh TODO enhancement
6+
7+
KEYWORD=$1
8+
LABEL=$2
9+
10+
if [ -z "$KEYWORD" ] || [ -z "$LABEL" ]; then
11+
echo "Usage: $0 <KEYWORD> <LABEL>"
12+
exit 1
13+
fi
14+
15+
# Find all files with the keyword, excluding certain directories
16+
grep -r "$KEYWORD:" --include="*.py" --include="*.lua" --include="*.js" --include="*.md" | while IFS= read -r line; do
17+
# Extract file, line number, and comment
18+
file=$(echo "$line" | cut -d: -f1)
19+
line_num=$(echo "$line" | cut -d: -f2)
20+
comment=$(echo "$line" | cut -d: -f3- | sed "s/.*$KEYWORD: *//" | sed 's/^[[:space:]]*//')
21+
22+
# Skip if comment is empty
23+
if [ -z "$comment" ]; then
24+
continue
25+
fi
26+
27+
# Create issue title and body
28+
title="[$KEYWORD] $comment"
29+
body="Found in \`$file\` at line $line_num:
30+
31+
\`\`\`
32+
$comment
33+
\`\`\`
34+
35+
"
36+
37+
# Check if issue already exists
38+
existing=$(gh issue list --search "$title" --json title --jq '.[].title' | grep -F "$title" || true)
39+
40+
if [ -z "$existing" ]; then
41+
echo "Creating issue: $title"
42+
gh issue create --title "$title" --body "$body" --label "$LABEL"
43+
else
44+
echo "Issue already exists: $title"
45+
fi
46+
done

.github/workflows/workflow.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Run TODO to Issue"
2+
3+
on: [push]
4+
5+
permissions:
6+
issues: write
7+
contents: read
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
env:
13+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Install GitHub CLI
20+
run: |
21+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
22+
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
23+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
24+
&& sudo apt update \
25+
&& sudo apt install gh -y
26+
27+
- name: Set script to executable
28+
run: chmod +x .github/scripts/todo_fixme_to_issues.sh
29+
30+
- name: Find TODOs and create issues
31+
run: .github/scripts/todo_fixme_to_issues.sh TODO enhancement
32+
33+
- name: Find BUGs and create issues
34+
run: .github/scripts/todo_fixme_to_issues.sh FIXME bug
35+
36+

0 commit comments

Comments
 (0)