mirror of
https://github.com/andwati/gitea-mirror-sync.git
synced 2026-10-18 03:12:53 +00:00
Add .gitignore and enhance Gitea mirror script for repo visibility updates
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
|||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Editor
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# Env / secrets — never commit real tokens
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# Logs / temp
|
||||||
|
*.log
|
||||||
|
/tmp/
|
||||||
@@ -33,12 +33,32 @@ echo "$repos_json" | jq -c '.[] | {name, private}' | while read -r entry; do
|
|||||||
echo "Processing: ${name} (private=${private})"
|
echo "Processing: ${name} (private=${private})"
|
||||||
|
|
||||||
# Check if it already exists in Gitea
|
# Check if it already exists in Gitea
|
||||||
existing_status=$(curl -s -o /dev/null -w "%{http_code}" \
|
existing_resp=$(curl -s -w "\n%{http_code}" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
"${GITEA_URL}/api/v1/repos/${GITEA_OWNER}/${name}")
|
"${GITEA_URL}/api/v1/repos/${GITEA_OWNER}/${name}")
|
||||||
|
existing_status=$(echo "$existing_resp" | tail -n1)
|
||||||
|
existing_body=$(echo "$existing_resp" | sed '$d')
|
||||||
|
|
||||||
if [ "$existing_status" == "200" ]; then
|
if [ "$existing_status" == "200" ]; then
|
||||||
echo " Already mirrored, skipping migration (existing mirror syncs on its own schedule)."
|
gitea_private=$(echo "$existing_body" | jq -r '.private')
|
||||||
|
|
||||||
|
if [ "$gitea_private" != "$private" ]; then
|
||||||
|
echo " Already mirrored, but visibility differs (GitHub private=${private}, Gitea private=${gitea_private}). Syncing..."
|
||||||
|
patch_code=$(curl -s -o /tmp/gitea_patch_resp.json -w "%{http_code}" \
|
||||||
|
-X PATCH "${GITEA_URL}/api/v1/repos/${GITEA_OWNER}/${name}" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"private\": ${private}}")
|
||||||
|
|
||||||
|
if [ "$patch_code" == "200" ]; then
|
||||||
|
echo " Visibility updated to private=${private}."
|
||||||
|
else
|
||||||
|
echo " Failed to update visibility (HTTP ${patch_code}):"
|
||||||
|
cat /tmp/gitea_patch_resp.json
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " Already mirrored, visibility already matches (private=${gitea_private}). Skipping."
|
||||||
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user