diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 2d560e4..b2912da 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -31,16 +31,16 @@ jobs: - name: Generate Skin Data Files id: generate_data - shell: bash # Changed to bash for array support and better process substitution + shell: bash run: | - set -euo pipefail # Exit on error, unset variable, or pipeline failure + set -euo pipefail total_valid_entries=0 user_rows_file=$(mktemp) avatar_rows_file=$(mktemp) page=1 - users_data_found=true # Flag to control the outer loop + users_data_found=true while "$users_data_found"; do echo "Fetching users page $page..." >&2 users_json=$(curl --fail --retry 3 --retry-delay 5 -sSL \ @@ -61,24 +61,31 @@ jobs: -H "Authorization: token ${{ secrets.TOKEN }}" \ "$GITEA_API/users/$user_login/repos?limit=50&page=1&_ts=$(date +%s)") - if ! echo "$repos_json" | jq -e '.[0]' >/dev/null; then # Check if it's an empty array + if ! echo "$repos_json" | jq -e '.[0]' >/dev/null; then continue fi mapfile -t repo_details < <(echo "$repos_json" | jq -r '.[] | .owner.login, .name, .html_url') - for ((i=0; i<${#repo_details[@]}; i+=3)); do # THIS LOOP STARTS HERE + for ((i=0; i<${#repo_details[@]}; i+=3)); do owner="${repo_details[i]}" repo="${repo_details[i+1]}" html_url="${repo_details[i+2]}" echo " Checking repo: $repo" >&2 - if ! http_code=$(curl --fail --retry 3 --retry-delay 5 -s -w "%{http_code}" -o readme_content.json \ + + curl_output=$(curl --fail --retry 3 --retry-delay 5 -s -w "%{http_code}" -o readme_content.json \ -H "Authorization: token ${{ secrets.TOKEN }}" \ - "$GITEA_API/repos/$owner/$repo/contents/README.md?_ts=$(date +%s)"); then + "$GITEA_API/repos/$owner/$repo/contents/README.md?_ts=$(date +%s)") + + curl_exit=$? + http_code="$curl_output" + + if [ $curl_exit -ne 0 ]; then echo "Failed to fetch README for $owner/$repo (HTTP $http_code)" >&2 continue fi + if [ "$http_code" != "200" ]; then echo "README not found for $owner/$repo (HTTP $http_code)" >&2 continue @@ -121,10 +128,10 @@ jobs: else echo "README for $owner/$repo does not match required format" >&2 fi - done # <--- ADDED THIS MISSING 'done' for the for ((i=0; i<${#repo_details[@]}; i+=3)) loop - done # End of for user_logins loop + done + done page=$((page + 1)) - done # End of while users_data_found loop + done echo "user_rows_file=$user_rows_file" >> "$GITHUB_OUTPUT" echo "avatar_rows_file=$avatar_rows_file" >> "$GITHUB_OUTPUT" @@ -212,4 +219,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 \ No newline at end of file + fi