wth
This commit is contained in:
@@ -33,10 +33,10 @@ jobs:
|
||||
token: ${{ secrets.TOKEN }}
|
||||
|
||||
- id: fetch-skins-data
|
||||
name: Find Skin Repositories and Generate Tables
|
||||
name: Find Repos Containing /Skins Directory
|
||||
run: |
|
||||
set -eo pipefail
|
||||
mkdir -p $ARTIFACT_PATH
|
||||
mkdir -p "$ARTIFACT_PATH"
|
||||
total_valid_entries=0
|
||||
|
||||
page=1
|
||||
@@ -47,62 +47,61 @@ jobs:
|
||||
count=$(echo "$users_json" | jq 'length')
|
||||
[ "$count" -eq 0 ] && break
|
||||
|
||||
echo "📄 Found $count users on page $page"
|
||||
|
||||
for i in $(seq 0 $((count - 1))); do
|
||||
user_login=$(echo "$users_json" | jq -r ".[$i].login")
|
||||
echo "🔍 User: $user_login"
|
||||
|
||||
repos_json=$(curl --retry 3 --retry-delay 5 -sSL \
|
||||
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
||||
"$GITEA_API/users/$user_login/repos?_ts=$(date +%s)")
|
||||
if ! echo "$repos_json" | jq -e . >/dev/null 2>&1; then continue; fi
|
||||
|
||||
if ! echo "$repos_json" | jq -e . >/dev/null 2>&1; then
|
||||
echo " ⚠️ Could not parse repos for $user_login"
|
||||
continue
|
||||
fi
|
||||
|
||||
repos_count=$(echo "$repos_json" | jq 'length')
|
||||
echo " 📦 $repos_count repos found"
|
||||
[ "$repos_count" -eq 0 ] && continue
|
||||
|
||||
for j in $(seq 0 $((repos_count - 1))); do
|
||||
owner=$(echo "$repos_json" | jq -r ".[$j].owner.login")
|
||||
repo=$(echo "$repos_json" | jq -r ".[$j].name")
|
||||
html_url=$(echo "$repos_json" | jq -r ".[$j].html_url")
|
||||
echo " → Repo: $owner/$repo"
|
||||
|
||||
dir_code=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" -o temp_dir.json \
|
||||
dir_code=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" -o /dev/null \
|
||||
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
||||
"$GITEA_API/repos/$owner/$repo/contents/Skins?_ts=$(date +%s)")
|
||||
[ "$dir_code" != "200" ] && continue
|
||||
|
||||
readme_code=$(curl --retry 3 --retry-delay 5 -s -w "%{http_code}" -o temp_readme.json \
|
||||
-H "Authorization: token ${{ secrets.TOKEN }}" \
|
||||
"$GITEA_API/repos/$owner/$repo/contents/README.md?_ts=$(date +%s)")
|
||||
[ "$readme_code" != "200" ] && continue
|
||||
if [ "$dir_code" = "200" ]; then
|
||||
echo " ✅ /Skins directory found"
|
||||
|
||||
content=$(jq -r .content < temp_readme.json | base64 -d || echo "")
|
||||
osu_id=$(echo "$content" | awk '/osuid:[ ]*[0-9]+/ { match($0, /[0-9]+/); print substr($0, RSTART, RLENGTH); exit }')
|
||||
[ -z "$osu_id" ] && continue
|
||||
printf "%07d|<tr><td>%s</td><td>%s</td><td>%s</td><td>-</td><td><a href=\"%s\">Skins</a></td></tr>\n" \
|
||||
"$((9999999 + total_valid_entries))" "$user_login" "-" "-" "$html_url" >> "$USER_ROWS_FILE"
|
||||
|
||||
user_data=$(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)")
|
||||
[ "$(echo "$user_data" | jq 'length')" -eq 0 ] && continue
|
||||
|
||||
pp_rank=$(echo "$user_data" | jq -r '.[0].pp_rank // "9999999"')
|
||||
pp_country_rank=$(echo "$user_data" | jq -r '.[0].pp_country_rank // "-"')
|
||||
username=$(echo "$user_data" | jq -r '.[0].username // "'$owner'"')
|
||||
padded_rank=$(printf "%07d" "$pp_rank")
|
||||
|
||||
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" "$pp_country_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"
|
||||
printf "%07d|<a href=\"%s\">🖼️</a>\n" "$((9999999 + total_valid_entries))" "$html_url" >> "$AVATAR_ROWS_FILE"
|
||||
|
||||
total_valid_entries=$((total_valid_entries + 1))
|
||||
else
|
||||
echo " ❌ Skipped: No /Skins directory (HTTP $dir_code)"
|
||||
fi
|
||||
done
|
||||
done
|
||||
page=$((page + 1))
|
||||
done
|
||||
|
||||
echo
|
||||
echo "✅ Total repos with /Skins: $total_valid_entries"
|
||||
|
||||
- id: upload-tables
|
||||
name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: skin-tables
|
||||
path: /data
|
||||
path: ${{ env.ARTIFACT_PATH }}
|
||||
|
||||
generate-readme:
|
||||
needs: gather-skins
|
||||
@@ -118,7 +117,7 @@ jobs:
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: skin-tables
|
||||
path: /data
|
||||
path: ${{ env.ARTIFACT_PATH }}
|
||||
|
||||
- id: checkout-code
|
||||
name: Checkout Repository
|
||||
|
||||
Reference in New Issue
Block a user