feat: colloborators
This commit is contained in:
parent
fe40d1be7f
commit
3bd5260fc3
@ -1,33 +1,36 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Fetch all private repositories where you are an owner or collaborator
|
# Fetch all private repositories where the user is an owner or collaborator
|
||||||
REPOS_DATA=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
|
REPO_DATA=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
|
||||||
"https://api.github.com/user/repos?per_page=100&affiliation=owner,collaborator&visibility=private")
|
"https://api.github.com/user/repos?per_page=100&affiliation=owner,collaborator&visibility=private")
|
||||||
|
|
||||||
# Extract repository names
|
# Extract repository names
|
||||||
REPOS=$(echo "$REPOS_DATA" | jq -r '.[].name')
|
REPO_LIST=$(echo "$REPO_DATA" | jq -r '.[].name')
|
||||||
|
|
||||||
if [[ -z "$REPOS" ]]; then
|
# Exit if no repositories found
|
||||||
echo "❌ No private repositories found or token missing 'repo' scope."
|
if [[ -z "$REPO_LIST" ]]; then
|
||||||
|
echo "❌ No private repositories found or token is missing the 'repo' scope."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Fetching contributors and owners from all private repositories..."
|
echo "🔍 Fetching collaborators for all private repositories..."
|
||||||
for REPO in $REPOS; do
|
for REPO in $REPO_LIST; do
|
||||||
# Extract the repo owner (useful if it belongs to an org)
|
# Determine the actual owner (useful for org-owned repos)
|
||||||
OWNER=$(echo "$REPOS_DATA" | jq -r --arg REPO "$REPO" '.[] | select(.name==$REPO) | .owner.login')
|
REPO_OWNER=$(echo "$REPO_DATA" | jq -r --arg REPO "$REPO" '.[] | select(.name==$REPO) | .owner.login')
|
||||||
|
|
||||||
echo "🔍 Scanning $REPO (Owner: $OWNER)..."
|
echo "📂 Repository: $REPO (Owner: $REPO_OWNER)"
|
||||||
|
|
||||||
# List contributors
|
# Fetch all collaborators (includes users even if they haven't committed)
|
||||||
CONTRIBUTORS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
|
COLLABORATORS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
|
||||||
"https://api.github.com/repos/$OWNER/$REPO/contributors" | jq -r '.[].login')
|
"https://api.github.com/repos/$REPO_OWNER/$REPO/collaborators" | jq -r '.[].login')
|
||||||
|
|
||||||
if [[ -z "$CONTRIBUTORS" ]]; then
|
# Display collaborators or notify if none found
|
||||||
echo "🚫 No contributors found. (Owner: $OWNER)"
|
if [[ -z "$COLLABORATORS" ]]; then
|
||||||
|
echo "🚫 No collaborators found."
|
||||||
else
|
else
|
||||||
echo "📌 Owner: $OWNER"
|
echo "👥 Collaborators:"
|
||||||
echo "$CONTRIBUTORS"
|
echo "$COLLABORATORS"
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
|
echo "--------------------------------------------"
|
||||||
|
done
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user