Update .gitea/workflows/ci.yml
This commit is contained in:
@@ -36,7 +36,6 @@ jobs:
|
|||||||
name: Find Skin Repositories and Generate Tables
|
name: Find Skin Repositories and Generate Tables
|
||||||
run: |
|
run: |
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
mkdir -p "$ARTIFACT_PATH"
|
mkdir -p "$ARTIFACT_PATH"
|
||||||
total_valid_entries=0
|
total_valid_entries=0
|
||||||
|
|
||||||
@@ -46,32 +45,36 @@ jobs:
|
|||||||
|
|
||||||
page=1
|
page=1
|
||||||
while :; do
|
while :; do
|
||||||
users_json=$(curl --retry 3 --retry-delay 5 -sSL \
|
# Fetch user list
|
||||||
|
users_response=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" \
|
||||||
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
||||||
"$GITEA_API/admin/users?limit=50&page=$page&_ts=$(date +%s)")
|
"$GITEA_API/admin/users?limit=50&page=$page&_ts=$(date +%s)")
|
||||||
|
|
||||||
if ! echo "$users_json" | json_valid; then
|
users_code=$(printf "%s" "$users_response" | tail -c 3)
|
||||||
echo "❌ Invalid users JSON on page $page. Skipping."
|
users_json=$(printf "%s" "$users_response" | head -c -3)
|
||||||
echo "$users_json" > "$ARTIFACT_PATH/invalid_users_page_$page.json"
|
|
||||||
|
if [ "$users_code" != "200" ] || ! echo "$users_json" | json_valid; then
|
||||||
|
echo "❌ Invalid users JSON on page $page (HTTP $users_code)"
|
||||||
|
echo "$users_json" > "$ARTIFACT_PATH/invalid_users_page_${page}.json"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
count=$(echo "$users_json" | jq 'length')
|
count=$(echo "$users_json" | jq 'length')
|
||||||
[ "$count" -eq 0 ] && break
|
[ "$count" -eq 0 ] && break
|
||||||
|
|
||||||
echo "📄 Found $count users on page $page"
|
echo "📄 Found $count users on page $page"
|
||||||
|
|
||||||
|
# Loop through users
|
||||||
for i in $(seq 0 $((count - 1))); do
|
for i in $(seq 0 $((count - 1))); do
|
||||||
user_login=$(echo "$users_json" | jq -r ".[$i].login")
|
user_login=$(echo "$users_json" | jq -r ".[$i].login")
|
||||||
echo "🔍 User: $user_login"
|
echo "🔍 User: $user_login"
|
||||||
|
|
||||||
# Fetch repos
|
# Fetch repos for user
|
||||||
repos_response=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" \
|
repos_response=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" \
|
||||||
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
||||||
"$GITEA_API/users/$user_login/repos?_ts=$(date +%s)")
|
"$GITEA_API/users/$user_login/repos?_ts=$(date +%s)")
|
||||||
|
|
||||||
repos_code="${repos_response: -3}"
|
repos_code=$(printf "%s" "$repos_response" | tail -c 3)
|
||||||
repos_json="${repos_response::-3}"
|
repos_json=$(printf "%s" "$repos_response" | head -c -3)
|
||||||
|
|
||||||
if [ "$repos_code" != "200" ] || ! echo "$repos_json" | json_valid; then
|
if [ "$repos_code" != "200" ] || ! echo "$repos_json" | json_valid; then
|
||||||
echo " ❌ Invalid repo list for $user_login (HTTP $repos_code)"
|
echo " ❌ Invalid repo list for $user_login (HTTP $repos_code)"
|
||||||
@@ -84,6 +87,7 @@ jobs:
|
|||||||
|
|
||||||
[ "$repos_count" -eq 0 ] && continue
|
[ "$repos_count" -eq 0 ] && continue
|
||||||
|
|
||||||
|
# Loop through repos
|
||||||
for j in $(seq 0 $((repos_count - 1))); do
|
for j in $(seq 0 $((repos_count - 1))); do
|
||||||
owner=$(echo "$repos_json" | jq -r ".[$j].owner.login")
|
owner=$(echo "$repos_json" | jq -r ".[$j].owner.login")
|
||||||
repo=$(echo "$repos_json" | jq -r ".[$j].name")
|
repo=$(echo "$repos_json" | jq -r ".[$j].name")
|
||||||
@@ -91,11 +95,12 @@ jobs:
|
|||||||
|
|
||||||
echo " → Repo: $owner/$repo"
|
echo " → Repo: $owner/$repo"
|
||||||
|
|
||||||
# Check Skins/ directory
|
# Check Skins directory
|
||||||
dir_response=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" \
|
dir_response=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" \
|
||||||
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
||||||
"$GITEA_API/repos/$owner/$repo/contents/Skins?_ts=$(date +%s)")
|
"$GITEA_API/repos/$owner/$repo/contents/Skins?_ts=$(date +%s)")
|
||||||
dir_code="${dir_response: -3}"
|
|
||||||
|
dir_code=$(printf "%s" "$dir_response" | tail -c 3)
|
||||||
|
|
||||||
if [ "$dir_code" != "200" ]; then
|
if [ "$dir_code" != "200" ]; then
|
||||||
echo " ❌ Skipped: No Skins/ directory (HTTP $dir_code)"
|
echo " ❌ Skipped: No Skins/ directory (HTTP $dir_code)"
|
||||||
@@ -104,42 +109,44 @@ jobs:
|
|||||||
|
|
||||||
# Check README.md
|
# Check README.md
|
||||||
readme_response=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" \
|
readme_response=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" \
|
||||||
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
||||||
"$GITEA_API/repos/$owner/$repo/contents/README.md?_ts=$(date +%s)")
|
"$GITEA_API/repos/$owner/$repo/contents/README.md?_ts=$(date +%s)")
|
||||||
readme_code="${readme_response: -3}"
|
readme_code=$(printf "%s" "$readme_response" | tail -c 3)
|
||||||
readme_json="${readme_response::-3}"
|
readme_json=$(printf "%s" "$readme_response" | head -c -3)
|
||||||
|
|
||||||
if [ "$readme_code" != "200" ] || ! echo "$readme_json" | json_valid; then
|
if [ "$readme_code" != "200" ] || ! echo "$readme_json" | json_valid; then
|
||||||
echo " ❌ Skipped: No README.md or JSON invalid (HTTP $readme_code)"
|
echo " ❌ Skipped: No README.md or invalid JSON (HTTP $readme_code)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
content=$(echo "$readme_json" | jq -r .content | base64 -d || echo "")
|
# Decode README content
|
||||||
|
content=$(echo "$readme_json" | jq -r .content | base64 -d 2>/dev/null || echo "")
|
||||||
|
|
||||||
# Extract osuid
|
# Extract osuid
|
||||||
osu_id=$(echo "$content" | grep -oE "osuid:[ ]*[0-9]+" | grep -oE "[0-9]+" | head -1)
|
osu_id=$(printf "%s" "$content" | grep -oE "osuid:[ ]*[0-9]+" | grep -oE "[0-9]+" | head -1)
|
||||||
|
|
||||||
if [ -z "$osu_id" ]; then
|
if [ -z "$osu_id" ]; then
|
||||||
echo " ❌ Skipped: No osuid in README"
|
echo " ❌ Skipped: No osuid in README"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fetch osu! user data
|
# Fetch osu! API
|
||||||
user_data=$(curl -s \
|
osu_response=$(curl --retry 3 --retry-delay 5 -s \
|
||||||
"https://osu.ppy.sh/api/get_user?k=${{ secrets.OSUAPIV1 }}&u=$osu_id&type=id&_ts=$(date +%s)")
|
"https://osu.ppy.sh/api/get_user?k=${{ secrets.OSUAPIV1 }}&u=$osu_id&type=id&_ts=$(date +%s)")
|
||||||
|
|
||||||
if ! echo "$user_data" | json_valid; then
|
if ! echo "$osu_response" | json_valid; then
|
||||||
echo " ❌ Invalid osu! API response for $osu_id"
|
echo " ❌ Invalid osu! API JSON for $osu_id"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(echo "$user_data" | jq 'length')" -eq 0 ]; then
|
if [ "$(echo "$osu_response" | jq 'length')" -eq 0 ]; then
|
||||||
echo " 🚫 Restricted or banned user"
|
echo " 🚫 Restricted or banned user"
|
||||||
|
|
||||||
username="$owner"
|
username="$owner"
|
||||||
pp_rank="RESTRICTED"
|
pp_rank="RESTRICTED"
|
||||||
pp_country_rank="RESTRICTED"
|
pp_country_rank="RESTRICTED"
|
||||||
padded_rank="9999999"
|
padded_rank="9999999"
|
||||||
|
|
||||||
profile_url="https://osu.ppy.sh/users/$osu_id"
|
profile_url="https://osu.ppy.sh/users/$osu_id"
|
||||||
avatar_url="https://a.ppy.sh/$osu_id?$(( $(date +%s)/86400*86400 ))"
|
avatar_url="https://a.ppy.sh/$osu_id?$(( $(date +%s)/86400*86400 ))"
|
||||||
|
|
||||||
@@ -153,11 +160,12 @@ jobs:
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Normal user
|
# Normal account
|
||||||
pp_rank=$(echo "$user_data" | jq -r '.[0].pp_rank // "9999999"')
|
pp_rank=$(echo "$osu_response" | jq -r '.[0].pp_rank // "9999999"')
|
||||||
pp_country_rank=$(echo "$user_data" | jq -r '.[0].pp_country_rank // "-"')
|
pp_country_rank=$(echo "$osu_response" | jq -r '.[0].pp_country_rank // "-"')
|
||||||
country=$(echo "$user_data" | jq -r '.[0].country // "-"')
|
country=$(echo "$osu_response" | jq -r '.[0].country // "-"')
|
||||||
username=$(echo "$user_data" | jq -r '.[0].username // "'$owner'"')
|
username=$(echo "$osu_response" | jq -r '.[0].username // "'$owner'"')
|
||||||
|
|
||||||
padded_rank=$(printf "%07d" "$pp_rank")
|
padded_rank=$(printf "%07d" "$pp_rank")
|
||||||
|
|
||||||
if [ "$pp_country_rank" != "-" ] && [ "$country" != "-" ]; then
|
if [ "$pp_country_rank" != "-" ] && [ "$country" != "-" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user