You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/process-new-resource.yml
+19-46Lines changed: 19 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -125,89 +125,62 @@ jobs:
125
125
fi
126
126
127
127
URL="${{ steps.parse.outputs.url }}"
128
-
128
+
129
129
# Create formatted entry using AI
130
130
ENTRY_LINE=$(gh models run openai/gpt-4o-mini "Create a markdown list entry for: URL=$URL, Description=$DESC. Format: '- [Site Name](url) Description'. Extract site name from URL domain.")
131
-
131
+
132
132
# Dynamically find the section header using AI
133
133
README_HEADERS=$(grep '^##' README.md)
134
-
135
-
SECTION_HEADER=$(gh models run openai/gpt-4o-mini "Find the exact section header that matches category '$CAT'.
136
-
137
-
Available README section headers:
138
-
$README_HEADERS
139
134
140
-
Category to match: $CAT
135
+
SECTION_HEADER=$(gh models run openai/gpt-4o-mini "Find the exact section header that matches category '$CAT'. Available headers: $README_HEADERS. Rules: 1) Match to most appropriate section 2) For subcategories like 'Exterior - Bumpers' match to '### Bumpers' 3) Return ONLY the exact header text with ## or ###. Examples: 'Van Builds' → '## Van Builds', 'Exterior - Bumpers' → '### Bumpers', 'Heating and AC' → '## Heating and Air Conditioning'")
141
136
142
-
Rules:
143
-
1. Match the category to the most appropriate section header
144
-
2. For subcategories like 'Exterior - Bumpers', match to the subsection '### Bumpers'
145
-
3. Return ONLY the exact header text (including ## or ###)
146
-
4. If no perfect match, choose the closest one
147
-
148
-
Examples:
149
-
- 'Van Builds'→ '## Van Builds'
150
-
- 'Exterior - Bumpers'→ '### Bumpers'
151
-
- 'Heating and AC'→ '## Heating and Air Conditioning'")
152
-
153
137
# Fallback: if AI response is empty or invalid, try fuzzy matching
154
138
if [ -z "$SECTION_HEADER" ] || [[ ! "$SECTION_HEADER" =~ ^##.* ]]; then
155
139
echo "AI section detection failed, using fuzzy matching fallback"
156
140
SECTION_HEADER=$(echo "$README_HEADERS" | grep -i "$CAT" | head -n1)
157
-
141
+
158
142
# Final fallback: create a new section
159
143
if [ -z "$SECTION_HEADER" ]; then
160
144
SECTION_HEADER="## $CAT"
161
145
echo "Creating new section: $SECTION_HEADER"
162
146
fi
163
147
fi
164
-
148
+
165
149
# Find section boundaries
166
150
SECTION_START=$(grep -n "^$(echo "$SECTION_HEADER" | sed 's/[[\.*^$()+?{|]/\\&/g')" README.md | head -n1 | cut -d: -f1)
167
-
151
+
168
152
if [ -z "$SECTION_START" ]; then
169
153
echo "Error: Could not find section '$SECTION_HEADER' in README"
170
154
exit 1
171
155
fi
172
-
156
+
173
157
# Find end of section (next header at same or higher level)
UPDATED_SECTION=$(gh models run openai/gpt-4o-mini "Add this entry alphabetically to the section:
193
174
194
-
Entry to add: $ENTRY_LINE
195
-
196
-
Current section content:
197
-
$SECTION_CONTENT
198
-
199
-
Instructions:
200
-
1. Add the entry in alphabetical order within the list items
201
-
2. Return ONLY the updated section content
202
-
3. Maintain exact formatting and structure
203
-
4. Do not add explanations or comments")
175
+
# Use AI to add entry to just this section
176
+
UPDATED_SECTION=$(gh models run openai/gpt-4o-mini "Add this entry alphabetically: '$ENTRY_LINE'. Current section: '$SECTION_CONTENT'. Instructions: 1) Add entry in alphabetical order within list items 2) Return ONLY updated section content 3) Maintain exact formatting 4) No explanations")
204
177
205
178
# Create temporary file with updated content
206
179
head -n $((SECTION_START-1)) README.md > temp_readme.md
0 commit comments