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