Skip to content

Commit f8efd94

Browse files
vmrh21claude
andcommitted
fix: examples.md PRs go to component repos, not ambient-code/workflows
The mapping update PR goes to ambient-code/workflows (correct). The .cve-fix/examples.md files go as separate PRs to each component repo (e.g. stolostron/multicluster-observability-operator), not to the workflows repo. Two separate PRs created per /onboard run: 1. ambient-code/workflows ← mapping update only 2. Each component repo ← .cve-fix/examples.md only Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent d3170e2 commit f8efd94

1 file changed

Lines changed: 68 additions & 15 deletions

File tree

workflows/cve-fixer/.claude/commands/onboard.md

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -316,26 +316,16 @@ to `ambient-code/workflows` containing both the mapping update and the guidance
316316
python3 -m json.tool "$MAPPING_FILE" > /dev/null && echo "✅ JSON valid"
317317
git add "$MAPPING_FILE"
318318
319-
# Add .cve-fix/examples.md for each repo
320-
for i in "${!REPO_URLS[@]}"; do
321-
REPO_FULL=$(echo "${REPO_URLS[$i]}" | sed 's|https://github.com/||')
322-
EXAMPLES_DIR="workflows/cve-fixer/.cve-fix/$(echo "$REPO_FULL" | tr '/' '-')"
323-
mkdir -p "$EXAMPLES_DIR"
324-
echo "${GENERATED_EXAMPLES[$i]}" > "${EXAMPLES_DIR}/examples.md"
325-
git add "${EXAMPLES_DIR}/examples.md"
326-
done
327-
328319
git commit -m "feat: onboard ${COMPONENT_NAME} to CVE fixer workflow
329320
330-
- Add ${COMPONENT_NAME} to component-repository-mappings.json
331-
- Generate .cve-fix/examples.md guidance for each repo
321+
Add ${COMPONENT_NAME} to component-repository-mappings.json
332322
333323
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>"
334324
335325
git push "$REMOTE" "$BRANCH_NAME"
336326
```
337327
338-
8. **Create Pull Request**
328+
8. **Create PR to `ambient-code/workflows`** (mapping update only)
339329
340330
```bash
341331
gh pr create \
@@ -360,12 +350,72 @@ to `ambient-code/workflows` containing both the mapping update and the guidance
360350
- [ ] Verify Jira component name matches exactly
361351
- [ ] Verify repo URLs and active branch names
362352
- [ ] Add container image names if missing
363-
- [ ] Review generated examples.md files
364353
365354
🤖 Generated by /onboard"
366355
```
367356
368-
9. **Cleanup**
357+
9. **Open separate PRs to each component repo** with `.cve-fix/examples.md`
358+
359+
The guidance files go to the COMPONENT repos themselves, not to `ambient-code/workflows`.
360+
For each repo in the component:
361+
362+
```bash
363+
for i in "${!REPO_URLS[@]}"; do
364+
REPO_FULL=$(echo "${REPO_URLS[$i]}" | sed 's|https://github.com/||')
365+
REPO_DIR="/tmp/onboard-${REPO_FULL//\//-}"
366+
367+
# Check write access / fork if needed
368+
PUSH_ACCESS=$(gh api repos/${REPO_FULL} --jq '.permissions.push' 2>/dev/null)
369+
FORK_USER=$(gh api user --jq '.login' 2>/dev/null)
370+
371+
if [ "$PUSH_ACCESS" != "true" ]; then
372+
gh repo fork "$REPO_FULL" --clone=false 2>/dev/null || true
373+
gh repo sync "${FORK_USER}/$(echo $REPO_FULL | cut -d/ -f2)" --source "$REPO_FULL" --branch main
374+
git clone "https://github.com/${FORK_USER}/$(echo $REPO_FULL | cut -d/ -f2).git" "$REPO_DIR"
375+
REPO_REMOTE="origin"
376+
PR_HEAD="${FORK_USER}:add-cve-fix-guidance"
377+
else
378+
git clone "https://github.com/${REPO_FULL}.git" "$REPO_DIR"
379+
REPO_REMOTE="origin"
380+
PR_HEAD="add-cve-fix-guidance"
381+
fi
382+
383+
cd "$REPO_DIR"
384+
git checkout -b add-cve-fix-guidance
385+
mkdir -p .cve-fix
386+
echo "${GENERATED_EXAMPLES[$i]}" > .cve-fix/examples.md
387+
git add .cve-fix/examples.md
388+
git commit -m "chore: add CVE fixer guidance file
389+
390+
Generated by /onboard — teaches the CVE fixer workflow how to create
391+
fix PRs matching this repo's conventions.
392+
393+
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>"
394+
git push "$REPO_REMOTE" add-cve-fix-guidance
395+
396+
gh pr create \
397+
--repo "$REPO_FULL" \
398+
--base main \
399+
--head "$PR_HEAD" \
400+
--title "chore: add .cve-fix/examples.md guidance for CVE fixer workflow" \
401+
--body "Adds \`.cve-fix/examples.md\` so the CVE fixer workflow knows how to
402+
create fix PRs matching this repo's conventions (branch naming, files that
403+
change together, co-upgrades, etc.).
404+
405+
Generated by \`/onboard\` based on analysis of ${CVE_COUNT} merged CVE PRs.
406+
407+
🤖 Generated by /onboard"
408+
409+
cd /tmp
410+
rm -rf "$REPO_DIR"
411+
done
412+
```
413+
414+
**This is separate from the workflows PR** — each component repo gets its own PR
415+
with just the `.cve-fix/examples.md` file. The reviewer merges it into their repo,
416+
and the CVE fixer will use it automatically on the next run.
417+
418+
10. **Cleanup**
369419
370420
```bash
371421
rm -rf /tmp/workflows-onboard
@@ -383,4 +433,7 @@ to `ambient-code/workflows` containing both the mapping update and the guidance
383433
- Branch info is auto-discovered from GitHub — review and correct if needed
384434
- Container image names can be added later by editing the mapping or re-running `/onboard`
385435
- Generated `.cve-fix/examples.md` improves over time — run `/guidance.update` after more CVE PRs are merged
386-
- Fork of `ambient-code/workflows` is created automatically if you lack write access
436+
- **Two separate PRs are created**:
437+
1. PR to `ambient-code/workflows` — adds the component to the mapping file
438+
2. Separate PRs to each component repo — adds `.cve-fix/examples.md` guidance files
439+
- Fork of the target repo is created automatically if you lack write access to it

0 commit comments

Comments
 (0)