ops: add failure reason
This commit is contained in:
parent
35934690be
commit
ff5883c97e
@ -16,17 +16,39 @@ echo "🔍 Checking and updating repositories to private..."
|
||||
while IFS= read -r REPO_FULL_NAME; do
|
||||
echo "🔄 Processing repository: $REPO_FULL_NAME..."
|
||||
|
||||
# Check the current privacy status
|
||||
# Get repository details
|
||||
REPO_INFO=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
|
||||
"https://api.github.com/repos/$REPO_FULL_NAME")
|
||||
|
||||
IS_PRIVATE=$(echo "$REPO_INFO" | jq -r '.private')
|
||||
IS_FORK=$(echo "$REPO_INFO" | jq -r '.fork')
|
||||
HAS_ADMIN_ACCESS=$(echo "$REPO_INFO" | jq -r '.permissions.admin')
|
||||
IS_GITHUB_PAGES=$(echo "$REPO_INFO" | jq -r '.name' | grep -i '\.github\.io')
|
||||
|
||||
# Skip if already private
|
||||
if [[ "$IS_PRIVATE" == "true" ]]; then
|
||||
echo "✅ Repository '$REPO_FULL_NAME' is already private. Skipping..."
|
||||
continue
|
||||
fi
|
||||
|
||||
# Skip if the repo is a fork (GitHub doesn't allow making forked repos private)
|
||||
if [[ "$IS_FORK" == "true" ]]; then
|
||||
echo "⚠️ Skipping '$REPO_FULL_NAME' because it is a forked repository."
|
||||
continue
|
||||
fi
|
||||
|
||||
# Skip if the repo is a GitHub Pages site
|
||||
if [[ -n "$IS_GITHUB_PAGES" ]]; then
|
||||
echo "⚠️ Skipping '$REPO_FULL_NAME' because it is a GitHub Pages site."
|
||||
continue
|
||||
fi
|
||||
|
||||
# Skip if the user doesn't have admin access
|
||||
if [[ "$HAS_ADMIN_ACCESS" != "true" ]]; then
|
||||
echo "❌ Skipping '$REPO_FULL_NAME' because you do NOT have admin permissions."
|
||||
continue
|
||||
fi
|
||||
|
||||
# Convert the repository to private
|
||||
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X PATCH -H "Authorization: token $GITHUB_TOKEN" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user