update-registry.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: Update Component Registry (Direct Push)
  2. on:
  3. push:
  4. branches:
  5. - main
  6. paths:
  7. - '.opencode/**'
  8. - '!registry.json'
  9. workflow_dispatch:
  10. permissions:
  11. contents: write
  12. jobs:
  13. update-and-validate-registry:
  14. runs-on: ubuntu-latest
  15. steps:
  16. - name: Checkout repository
  17. uses: actions/checkout@v4
  18. with:
  19. fetch-depth: 0
  20. - name: Install dependencies
  21. run: |
  22. sudo apt-get update
  23. sudo apt-get install -y jq
  24. - name: Make scripts executable
  25. run: |
  26. chmod +x scripts/registry/validate-registry.sh
  27. chmod +x scripts/registry/auto-detect-components.sh
  28. chmod +x scripts/registry/register-component.sh
  29. - name: Auto-detect new components
  30. id: auto_detect
  31. run: |
  32. echo "## 🔍 Auto-Detection Results" >> $GITHUB_STEP_SUMMARY
  33. echo "" >> $GITHUB_STEP_SUMMARY
  34. # Run auto-detect in dry-run mode first
  35. if ./scripts/registry/auto-detect-components.sh --dry-run > /tmp/detect-output.txt 2>&1; then
  36. cat /tmp/detect-output.txt >> $GITHUB_STEP_SUMMARY
  37. # Check if new components were found
  38. if grep -q "Found.*new component" /tmp/detect-output.txt; then
  39. echo "new_components=true" >> $GITHUB_OUTPUT
  40. echo "" >> $GITHUB_STEP_SUMMARY
  41. echo "⚠️ New components detected - will auto-add to registry" >> $GITHUB_STEP_SUMMARY
  42. else
  43. echo "new_components=false" >> $GITHUB_OUTPUT
  44. echo "✅ No new components found" >> $GITHUB_STEP_SUMMARY
  45. fi
  46. else
  47. echo "new_components=false" >> $GITHUB_OUTPUT
  48. echo "❌ Auto-detection failed" >> $GITHUB_STEP_SUMMARY
  49. fi
  50. - name: Add new components to registry
  51. if: steps.auto_detect.outputs.new_components == 'true'
  52. run: |
  53. echo "## 📝 Adding New Components" >> $GITHUB_STEP_SUMMARY
  54. echo "" >> $GITHUB_STEP_SUMMARY
  55. ./scripts/registry/auto-detect-components.sh --auto-add | tee -a $GITHUB_STEP_SUMMARY
  56. - name: Validate registry
  57. id: validate
  58. run: |
  59. echo "## ✅ Registry Validation" >> $GITHUB_STEP_SUMMARY
  60. echo "" >> $GITHUB_STEP_SUMMARY
  61. if ./scripts/registry/validate-registry.sh -v > /tmp/validation-output.txt 2>&1; then
  62. echo "validation=passed" >> $GITHUB_OUTPUT
  63. echo "✅ All registry paths are valid!" >> $GITHUB_STEP_SUMMARY
  64. echo "" >> $GITHUB_STEP_SUMMARY
  65. echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
  66. tail -20 /tmp/validation-output.txt >> $GITHUB_STEP_SUMMARY
  67. echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
  68. else
  69. echo "validation=failed" >> $GITHUB_OUTPUT
  70. echo "❌ Registry validation failed!" >> $GITHUB_STEP_SUMMARY
  71. echo "" >> $GITHUB_STEP_SUMMARY
  72. echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
  73. cat /tmp/validation-output.txt >> $GITHUB_STEP_SUMMARY
  74. echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
  75. echo "" >> $GITHUB_STEP_SUMMARY
  76. echo "⚠️ WARNING: Direct push to main with invalid registry!" >> $GITHUB_STEP_SUMMARY
  77. echo "Please fix registry.json and push a correction." >> $GITHUB_STEP_SUMMARY
  78. # Don't exit 1 here - we already pushed to main, just warn
  79. fi
  80. - name: Commit registry updates
  81. if: steps.auto_detect.outputs.new_components == 'true'
  82. run: |
  83. git config --local user.email "github-actions[bot]@users.noreply.github.com"
  84. git config --local user.name "github-actions[bot]"
  85. if ! git diff --quiet registry.json; then
  86. git add registry.json
  87. git commit -m "chore: auto-update registry with new components [skip ci]"
  88. git push
  89. echo "## 🚀 Registry Updated" >> $GITHUB_STEP_SUMMARY
  90. echo "" >> $GITHUB_STEP_SUMMARY
  91. echo "Registry has been automatically updated with new components." >> $GITHUB_STEP_SUMMARY
  92. fi
  93. - name: Summary
  94. if: always()
  95. run: |
  96. echo "" >> $GITHUB_STEP_SUMMARY
  97. echo "---" >> $GITHUB_STEP_SUMMARY
  98. echo "" >> $GITHUB_STEP_SUMMARY
  99. echo "### Registry Statistics" >> $GITHUB_STEP_SUMMARY
  100. echo "" >> $GITHUB_STEP_SUMMARY
  101. jq -r '
  102. "- **Agents:** \(.components.agents | length)",
  103. "- **Subagents:** \(.components.subagents | length)",
  104. "- **Commands:** \(.components.commands | length)",
  105. "- **Tools:** \(.components.tools | length)",
  106. "- **Plugins:** \(.components.plugins | length)",
  107. "- **Contexts:** \(.components.contexts | length)"
  108. ' registry.json >> $GITHUB_STEP_SUMMARY