Update .gitea/workflows/ci.yml
This commit is contained in:
@@ -43,16 +43,19 @@ jobs:
|
||||
jq -e . >/dev/null 2>&1
|
||||
}
|
||||
|
||||
curl_json() {
|
||||
body=$(mktemp)
|
||||
code=$(curl --retry 3 --retry-delay 5 -s -o "$body" -w "%{http_code}" "$1")
|
||||
printf "%s\n%s" "$code" "$body"
|
||||
fetch_json() {
|
||||
url="$1"
|
||||
body_file=$(mktemp)
|
||||
code=$(curl --retry 3 --retry-delay 5 -s -o "$body_file" -w "%{http_code}" "$url")
|
||||
echo "$code" "$body_file"
|
||||
}
|
||||
|
||||
page=1
|
||||
while :; do
|
||||
# Fetch user list
|
||||
read users_code users_body < <(curl_json "$GITEA_API/admin/users?limit=50&page=$page&_ts=$(date +%s)")
|
||||
# --- Fetch user list ---
|
||||
set -- $(fetch_json "$GITEA_API/admin/users?limit=50&page=$page&_ts=$(date +%s)")
|
||||
users_code="$1"
|
||||
users_body="$2"
|
||||
users_json=$(cat "$users_body")
|
||||
|
||||
if [ "$users_code" != "200" ] || ! printf "%s" "$users_json" | json_valid; then
|
||||
@@ -65,12 +68,15 @@ jobs:
|
||||
[ "$count" -eq 0 ] && break
|
||||
echo "📄 Found $count users on page $page"
|
||||
|
||||
# --- Loop through users ---
|
||||
for i in $(seq 0 $((count - 1))); do
|
||||
user_login=$(printf "%s" "$users_json" | jq -r ".[$i].login")
|
||||
echo "🔍 User: $user_login"
|
||||
|
||||
# Fetch repos
|
||||
read repos_code repos_body < <(curl_json "$GITEA_API/users/$user_login/repos?_ts=$(date +%s)")
|
||||
# --- Fetch repos list ---
|
||||
set -- $(fetch_json "$GITEA_API/users/$user_login/repos?_ts=$(date +%s)")
|
||||
repos_code="$1"
|
||||
repos_body="$2"
|
||||
repos_json=$(cat "$repos_body")
|
||||
|
||||
if [ "$repos_code" != "200" ] || ! printf "%s" "$repos_json" | json_valid; then
|
||||
@@ -81,9 +87,9 @@ jobs:
|
||||
|
||||
repos_count=$(printf "%s" "$repos_json" | jq 'length')
|
||||
echo " 📦 $repos_count repos found"
|
||||
|
||||
[ "$repos_count" -eq 0 ] && continue
|
||||
|
||||
# --- Loop through repos ---
|
||||
for j in $(seq 0 $((repos_count - 1))); do
|
||||
owner=$(printf "%s" "$repos_json" | jq -r ".[$j].owner.login")
|
||||
repo=$(printf "%s" "$repos_json" | jq -r ".[$j].name")
|
||||
@@ -91,15 +97,19 @@ jobs:
|
||||
|
||||
echo " → Repo: $owner/$repo"
|
||||
|
||||
# Check Skins directory
|
||||
read dir_code dir_body < <(curl_json "$GITEA_API/repos/$owner/$repo/contents/Skins?_ts=$(date +%s)")
|
||||
# --- Check Skins directory ---
|
||||
set -- $(fetch_json "$GITEA_API/repos/$owner/$repo/contents/Skins?_ts=$(date +%s)")
|
||||
dir_code="$1"
|
||||
|
||||
if [ "$dir_code" != "200" ]; then
|
||||
echo " ❌ Skipped: No Skins/ directory (HTTP $dir_code)"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check README.md
|
||||
read readme_code readme_body < <(curl_json "$GITEA_API/repos/$owner/$repo/contents/README.md?_ts=$(date +%s)")
|
||||
# --- Fetch README.md ---
|
||||
set -- $(fetch_json "$GITEA_API/repos/$owner/$repo/contents/README.md?_ts=$(date +%s)")
|
||||
readme_code="$1"
|
||||
readme_body="$2"
|
||||
readme_json=$(cat "$readme_body")
|
||||
|
||||
if [ "$readme_code" != "200" ] || ! printf "%s" "$readme_json" | json_valid; then
|
||||
@@ -107,6 +117,7 @@ jobs:
|
||||
continue
|
||||
fi
|
||||
|
||||
# Decode README
|
||||
content=$(printf "%s" "$readme_json" | jq -r .content | base64 -d 2>/dev/null || echo "")
|
||||
|
||||
osu_id=$(printf "%s" "$content" | grep -oE "osuid:[ ]*[0-9]+" | grep -oE "[0-9]+" | head -1)
|
||||
@@ -115,8 +126,10 @@ jobs:
|
||||
continue
|
||||
fi
|
||||
|
||||
# Fetch osu API
|
||||
read api_code api_body < <(curl_json "https://osu.ppy.sh/api/get_user?k=${{ secrets.OSUAPIV1 }}&u=$osu_id&type=id&_ts=$(date +%s)")
|
||||
# --- Fetch osu API ---
|
||||
set -- $(fetch_json "https://osu.ppy.sh/api/get_user?k=${{ secrets.OSUAPIV1 }}&u=$osu_id&type=id&_ts=$(date +%s)")
|
||||
api_code="$1"
|
||||
api_body="$2"
|
||||
osu_json=$(cat "$api_body")
|
||||
|
||||
if ! printf "%s" "$osu_json" | json_valid; then
|
||||
@@ -147,11 +160,11 @@ jobs:
|
||||
continue
|
||||
fi
|
||||
|
||||
# Normal user
|
||||
# Normal osu user
|
||||
pp_rank=$(printf "%s" "$osu_json" | jq -r '.[0].pp_rank // "9999999"')
|
||||
pp_country_rank=$(printf "%s" "$osu_json" | jq -r '.[0].pp_country_rank // "-"')
|
||||
country=$(printf "%s" "$osu_json" | jq -r '.[0].country // "-"')
|
||||
username=$(printf "%s" "$osu_json" | jq -r '.[0].username // "'$owner'"')
|
||||
username=$(printf "%s" "$osu_json" | jq -r '.[0].username')
|
||||
|
||||
padded_rank=$(printf "%07d" "$pp_rank")
|
||||
|
||||
@@ -161,11 +174,11 @@ jobs:
|
||||
cc_rank="-"
|
||||
fi
|
||||
|
||||
timestamp=$(( $(date +%s)/86400*86400 ))
|
||||
|
||||
printf "%s|<tr><td>%s</td><td>%s</td><td>%s</td><td><a href=\"https://osu.ppy.sh/users/%s\">Profile</a></td><td><a href=\"%s\">Skins</a></td></tr>\n" \
|
||||
"$padded_rank" "$username" "$pp_rank" "$cc_rank" "$osu_id" "$html_url" >> "$USER_ROWS_FILE"
|
||||
|
||||
timestamp=$(( $(date +%s)/86400*86400 ))
|
||||
|
||||
printf "%s|<a href=\"%s\"><img src=\"https://a.ppy.sh/%s?%s\" width=\"175\" height=\"175\"></a>\n" \
|
||||
"$padded_rank" "$html_url" "$osu_id" "$timestamp" >> "$AVATAR_ROWS_FILE"
|
||||
|
||||
@@ -179,6 +192,7 @@ jobs:
|
||||
|
||||
echo "✅ Total valid entries found: $total_valid_entries"
|
||||
|
||||
|
||||
- id: upload-tables
|
||||
name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
Reference in New Issue
Block a user