Separate in to more jobs

This commit is contained in:
Arlind
2025-06-25 13:40:28 +02:00
parent 717707e591
commit 4bab692602

View File

@@ -30,7 +30,6 @@ jobs:
- name: Pull latest changes
run: |
# Pull latest changes to prevent push conflicts
git fetch origin main
git rebase origin/main || {
echo "⚠️ Git rebase failed, likely due to conflicts."
@@ -42,9 +41,9 @@ jobs:
id: find_skins
run: |
set -eo pipefail
total_valid_entries=0
user_rows_file=$(mktemp)
avatar_rows_file=$(mktemp)
total_valid_entries=0
page=1
while :; do
@@ -54,71 +53,37 @@ jobs:
count=$(echo "$users_json" | jq 'length')
[ "$count" -eq 0 ] && break
echo "Found $count users on page $page"
echo
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
echo " ⚠️ Could not parse repos for $user_login"
echo
continue
fi
if ! echo "$repos_json" | jq -e . >/dev/null 2>&1; then continue; fi
repos_count=$(echo "$repos_json" | jq 'length')
echo " 📦 Found $repos_count repos"
if [ "$repos_count" -eq 0 ]; then
echo
continue
fi
[ "$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 \
-H "Authorization: token ${{ secrets.TOKEN }}" \
"$GITEA_API/repos/$owner/$repo/contents/Skins?_ts=$(date +%s)")
if [ "$dir_code" != "200" ]; then
echo " ❌ Skipped: No 'Skins/' directory found (HTTP $dir_code)"
continue
fi
[ "$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)")
if [ "$readme_code" != "200" ]; then
echo " ❌ Skipped: No README.md found to extract osuid (HTTP $readme_code)"
continue
fi
[ "$readme_code" != "200" ] && continue
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 }')
if [ -z "$osu_id" ]; then
echo " ❌ Skipped: osuid not found in README"
continue
fi
[ -z "$osu_id" ] && continue
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)")
if [ "$(echo "$user_data" | jq 'length')" -eq 0 ]; then
echo " ❌ Skipped: osu! API returned no data for osuid $osu_id"
continue
fi
[ "$(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 // "-"')
@@ -132,31 +97,24 @@ jobs:
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"
echo " ✅ Match: $username (Rank #$pp_rank), repo contains Skins/ directory"
total_valid_entries=$((total_valid_entries + 1))
done
done
page=$((page + 1))
done
{
echo "user_rows_file=$user_rows_file"
echo "avatar_rows_file=$avatar_rows_file"
echo "total_valid_entries=$total_valid_entries"
} >> "$GITHUB_OUTPUT"
echo
echo "✅ Total valid skin entries found: $total_valid_entries"
echo "user_rows_file=$user_rows_file" >> "$GITHUB_OUTPUT"
echo "avatar_rows_file=$avatar_rows_file" >> "$GITHUB_OUTPUT"
echo "total_valid_entries=$total_valid_entries" >> "$GITHUB_OUTPUT"
- name: Update README with user skins
id: update_readme
run: |
set -eo pipefail
README_PATH="${{ env.README_PATH }}"
user_rows_file="${{ steps.find_skins.outputs.user_rows_file }}"
avatar_rows_file="${{ steps.find_skins.outputs.avatar_rows_file }}"
total_valid_entries="${{ steps.find_skins.outputs.total_valid_entries }}"
README_PATH="${{ env.README_PATH }}"
if [ "$total_valid_entries" -eq 0 ]; then
echo "No valid entries found, skipping README update"
@@ -212,11 +170,11 @@ jobs:
if git diff --quiet "$README_PATH"; then
echo "README has not changed, skipping commit"
rm -rf "${README_PATH}.bak"
rm -f "${README_PATH}.bak"
exit 0
else
echo "README updated"
rm -rf "${README_PATH}.bak"
rm -f "${README_PATH}.bak"
fi
- name: Configure Git
@@ -237,4 +195,4 @@ jobs:
git push origin HEAD:main || echo "No changes to push"
else
git push origin HEAD:"${GITHUB_REF_NAME}" || echo "No changes to push"
fi
fi