mirror of
https://github.com/amalgamated-tools/mirror-to-gitea.git
synced 2025-12-23 22:18:05 -05:00
add debug script for testing Gitea and GitHub API access
This commit is contained in:
56
debug.sh
Executable file
56
debug.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Mirror to Gitea Debug Script"
|
||||
echo "============================="
|
||||
source .secrets.rc
|
||||
|
||||
# Get host machine IP address
|
||||
HOST_IP=$(ipconfig getifaddr en0)
|
||||
echo "Host IP: $HOST_IP"
|
||||
GITEA_URL_HOST=${GITEA_URL/localhost/$HOST_IP}
|
||||
echo "Gitea URL: $GITEA_URL"
|
||||
echo "Gitea URL for Docker: $GITEA_URL_HOST"
|
||||
|
||||
echo -e "\nTesting Gitea API access directly:"
|
||||
curl -s -H "Authorization: token $GITEA_TOKEN" "$GITEA_URL/api/v1/user" | jq '.'
|
||||
|
||||
echo -e "\nTesting GitHub token validity:"
|
||||
GITHUB_USER_RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/user")
|
||||
echo "$GITHUB_USER_RESPONSE" | jq '. | {login, name}'
|
||||
|
||||
echo -e "\nTesting GitHub organization access:"
|
||||
ORG_RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/user/orgs")
|
||||
ORG_COUNT=$(echo "$ORG_RESPONSE" | jq '. | length')
|
||||
if [ "$ORG_COUNT" -eq 0 ]; then
|
||||
echo "No organizations found. You may not be a member of any GitHub organizations."
|
||||
echo "Organizations response: $ORG_RESPONSE"
|
||||
else
|
||||
echo "$ORG_RESPONSE" | jq '.[].login'
|
||||
fi
|
||||
|
||||
echo -e "\nTesting GitHub starred repos access:"
|
||||
STARRED_RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/user/starred?per_page=1")
|
||||
STARRED_COUNT=$(echo "$STARRED_RESPONSE" | jq '. | length')
|
||||
if [ "$STARRED_COUNT" -eq 0 ]; then
|
||||
echo "No starred repositories found. You may not have starred any GitHub repositories."
|
||||
else
|
||||
echo "$STARRED_RESPONSE" | jq '.[].full_name'
|
||||
fi
|
||||
|
||||
echo -e "\nVerifying GitHub token scopes:"
|
||||
SCOPES=$(curl -s -I -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/user" | grep -i "x-oauth-scopes:" | cut -d ":" -f 2- | tr -d '\r')
|
||||
if [ -z "$SCOPES" ]; then
|
||||
echo "No scopes found in GitHub token"
|
||||
else
|
||||
echo "Your token has these scopes: $SCOPES"
|
||||
fi
|
||||
|
||||
echo -e "\nRequired scopes for full functionality:"
|
||||
echo "- repo (for repositories and issues)"
|
||||
echo "- read:org (for organization access)"
|
||||
echo "- user (for starred repositories)"
|
||||
|
||||
echo -e "\nYour environment should now be ready for testing."
|
||||
echo "Run ./run-local.sh to start the mirroring process."
|
||||
15
run-local.sh
15
run-local.sh
@@ -5,12 +5,25 @@ set -ex
|
||||
docker image build -t jaedle/mirror-to-gitea:development .
|
||||
source .secrets.rc
|
||||
|
||||
# Get host IP for Mac to connect to local Gitea instance
|
||||
HOST_IP=$(ipconfig getifaddr en0)
|
||||
echo "Using host IP for local Gitea: $HOST_IP"
|
||||
GITEA_URL_DOCKER=${GITEA_URL/localhost/$HOST_IP}
|
||||
echo "Gitea URL for Docker: $GITEA_URL_DOCKER"
|
||||
|
||||
docker container run \
|
||||
-it \
|
||||
--rm \
|
||||
-e GITHUB_USERNAME="$GITHUB_USERNAME" \
|
||||
-e GITEA_URL="$GITEA_URL" \
|
||||
-e GITEA_URL="$GITEA_URL_DOCKER" \
|
||||
-e GITEA_TOKEN="$GITEA_TOKEN" \
|
||||
-e GITHUB_TOKEN="$GITHUB_TOKEN" \
|
||||
-e MIRROR_PRIVATE_REPOSITORIES="true" \
|
||||
-e MIRROR_ISSUES="true" \
|
||||
-e MIRROR_STARRED="true" \
|
||||
-e MIRROR_ORGANIZATIONS="true" \
|
||||
-e INCLUDE_ORGS="$INCLUDE_ORGS" \
|
||||
-e EXCLUDE_ORGS="$EXCLUDE_ORGS" \
|
||||
-e PRESERVE_ORG_STRUCTURE="$PRESERVE_ORG_STRUCTURE" \
|
||||
-e DRY_RUN="true" \
|
||||
jaedle/mirror-to-gitea:development
|
||||
|
||||
Reference in New Issue
Block a user