Skip to content

Commit 4c0fa72

Browse files
authored
fix yaml (#99)
fix yamlk
1 parent 4561075 commit 4c0fa72

File tree

1 file changed

+19
-46
lines changed

1 file changed

+19
-46
lines changed

.github/workflows/process-new-resource.yml

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -125,89 +125,62 @@ jobs:
125125
fi
126126
127127
URL="${{ steps.parse.outputs.url }}"
128-
128+
129129
# Create formatted entry using AI
130130
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+
132132
# Dynamically find the section header using AI
133133
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
139134
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'")
141136
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-
153137
# Fallback: if AI response is empty or invalid, try fuzzy matching
154138
if [ -z "$SECTION_HEADER" ] || [[ ! "$SECTION_HEADER" =~ ^##.* ]]; then
155139
echo "AI section detection failed, using fuzzy matching fallback"
156140
SECTION_HEADER=$(echo "$README_HEADERS" | grep -i "$CAT" | head -n1)
157-
141+
158142
# Final fallback: create a new section
159143
if [ -z "$SECTION_HEADER" ]; then
160144
SECTION_HEADER="## $CAT"
161145
echo "Creating new section: $SECTION_HEADER"
162146
fi
163147
fi
164-
148+
165149
# Find section boundaries
166150
SECTION_START=$(grep -n "^$(echo "$SECTION_HEADER" | sed 's/[[\.*^$()+?{|]/\\&/g')" README.md | head -n1 | cut -d: -f1)
167-
151+
168152
if [ -z "$SECTION_START" ]; then
169153
echo "Error: Could not find section '$SECTION_HEADER' in README"
170154
exit 1
171155
fi
172-
156+
173157
# Find end of section (next header at same or higher level)
174158
if [[ "$SECTION_HEADER" == "###"* ]]; then
175159
# For subsections, find next ### or ## header
176160
SECTION_END=$(tail -n +$((SECTION_START+1)) README.md | grep -n "^##" | head -n1 | cut -d: -f1)
177161
else
178-
# For main sections, find next ## header
162+
# For main sections, find next ## header
179163
SECTION_END=$(tail -n +$((SECTION_START+1)) README.md | grep -n "^##" | head -n1 | cut -d: -f1)
180164
fi
181-
165+
182166
if [ -n "$SECTION_END" ]; then
183167
SECTION_END=$((SECTION_START + SECTION_END))
184168
else
185169
SECTION_END=$(wc -l < README.md)
186170
fi
187-
171+
188172
# Extract just the target section
189173
SECTION_CONTENT=$(sed -n "${SECTION_START},$((SECTION_END-1))p" README.md)
190-
191-
# Use AI to add entry to just this section
192-
UPDATED_SECTION=$(gh models run openai/gpt-4o-mini "Add this entry alphabetically to the section:
193174
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")
204177
205178
# Create temporary file with updated content
206179
head -n $((SECTION_START-1)) README.md > temp_readme.md
207180
echo "$UPDATED_SECTION" >> temp_readme.md
208181
tail -n +$SECTION_END README.md >> temp_readme.md
209182
mv temp_readme.md README.md
210-
183+
211184
echo "entry<<EOF" >> $GITHUB_OUTPUT
212185
echo "$ENTRY_LINE" >> $GITHUB_OUTPUT
213186
echo "EOF" >> $GITHUB_OUTPUT
@@ -302,20 +275,20 @@ Instructions:
302275
# Configure git
303276
git config user.name "github-actions[bot]"
304277
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
305-
278+
306279
# Create branch and commit changes
307280
BRANCH_NAME="add-resource-$(date +%s)"
308281
git checkout -b "$BRANCH_NAME"
309282
git add README.md
310283
git commit -m "Add new Ford Transit resource from issue #${{ github.event.issue.number }}
311284
312285
${{ steps.format.outputs.entry }}
313-
286+
314287
🤖 Generated with GitHub Actions"
315-
288+
316289
# Push branch
317290
git push origin "$BRANCH_NAME"
318-
291+
319292
# Create PR
320293
gh pr create \
321294
--title "Add Ford Transit resource: ${{ steps.ai_generate.outputs.description || steps.parse.outputs.manual_desc }}" \
@@ -324,12 +297,12 @@ Instructions:
324297
## Summary
325298
- Added new Ford Transit resource to **${{ steps.ai_generate.outputs.category || steps.parse.outputs.manual_cat }}** section
326299
- Entry: \`${{ steps.format.outputs.entry }}\`
327-
300+
328301
## Validation Results
329302
- ✅ URL accessible
330303
- ✅ No duplicates found
331304
${{ steps.ai_generate.outputs.appropriate && steps.ai_generate.outputs.appropriate.startsWith('YES') && '- ✅ Content appropriate' || '' }}
332-
305+
333306
🤖 Generated with GitHub Actions" \
334307
--label "new-resource"
335308
env:

0 commit comments

Comments
 (0)