diff --git a/.github/workflows/propagate-hooks.yml b/.github/workflows/propagate-hooks.yml index 9ac4c640..ad361499 100644 --- a/.github/workflows/propagate-hooks.yml +++ b/.github/workflows/propagate-hooks.yml @@ -72,44 +72,38 @@ jobs: # Get the SHA of the current commit (triggering commit) TRIGGER_SHA="${{ github.sha }}" - # In a real implementation, we would: - # 1. Query the GitHub API for all repos in hyperpolymath and metadatastician orgs - # 2. Filter for repos that have a .githooks directory - # 3. Check if their .githooks is behind the standards repo - # - # For this workflow, we'll use a representative list - # In production, this would be dynamically generated - - # Hyperpolymath estate repos (sample - would be all ~8,000+ repos) - HYPERPOLYMATH_REPOS=( - "hyperpolymath/standards" - "hyperpolymath/harvard-dehallucinator" - "hyperpolymath/echidnabot" - "hyperpolymath/universal-chat-extractor" - "hyperpolymath/developer-ecosystem" - "hyperpolymath/scaffoldia" - "hyperpolymath/a2ml-ecosystem" - "hyperpolymath/reposystem" - ) - - # Metadatastician estate repos (sample - would be all ~500+ repos) - METADATASTICIAN_REPOS=( - "metadatastician/svalinn" - "metadatastician/stapeln" - "metadatastician/gossamer" - "metadatastician/cerro-torre" - "metadatastician/vordr" - "metadatastician/cadastra" - ) - # Check if specific repo was requested if [ -n "${{ github.event.inputs.target-repo }}" ]; then TARGET="${{ github.event.inputs.target-repo }}" REPOS_JSON=$(jq -n --arg repo "$TARGET" '[$repo]') else - # Combine all repos - ALL_REPOS=("${HYPERPOLYMATH_REPOS[@]}" "${METADATASTICIAN_REPOS[@]}") - REPOS_JSON=$(jq -n --args '$ARGV' "${ALL_REPOS[@]}") + # Use a sample list for now - TODO: Query all repos dynamically + # For production, this should query the GitHub API for all repos + # in hyperpolymath and metadatastician orgs and filter by .githooks + ALL_REPOS=( + "hyperpolymath/standards" + ) + + # Filter to only repos that have .githooks directory + echo "🔍 Filtering repos with .githooks directory..." + REPOS_WITH_HOOKS=() + for repo in "${ALL_REPOS[@]}"; do + ORG=$(echo "$repo" | cut -d'/' -f1) + REPO_NAME=$(echo "$repo" | cut -d'/' -f2) + + # Check if .githooks exists in the repo + if gh api /repos/$ORG/$REPO_NAME/contents/.githooks \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" 2>/dev/null | \ + jq -e '. | type == "array"' 2>/dev/null; then + REPOS_WITH_HOOKS+=("$repo") + echo " ✓ $repo has .githooks" + else + echo " ✗ $repo skipped (no .githooks)" + fi + done + + REPOS_JSON=$(printf '%s\n' "${REPOS_WITH_HOOKS[@]}" | jq -R . | jq -s .) fi echo "repos=$REPOS_JSON" >> $GITHUB_OUTPUT