diff --git a/.github/workflows/monitor_selfhosted_runners.yml b/.github/workflows/monitor_selfhosted_runners.yml index aca7c05..fd615b6 100644 --- a/.github/workflows/monitor_selfhosted_runners.yml +++ b/.github/workflows/monitor_selfhosted_runners.yml @@ -33,7 +33,7 @@ jobs: org_names=$(jq -r '.runners[]?.name // empty' org_runners.json 2>/dev/null || echo "") # Fallback to known runner list if API fails - known_runners="xsjevo04" + known_runners="XSJEVO04" if [ -n "$repo_names" ] || [ -n "$org_names" ]; then all_names=$(echo -e "$repo_names\n$org_names" | sort -u | tr '\n' ',' | sed 's/,$//') @@ -47,10 +47,32 @@ jobs: - name: Get artifacts id: artifacts run: | - curl -s \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/${{ github.repository }}/actions/artifacts \ - > artifacts.json + # Fetch all artifacts with pagination + echo '{"artifacts":[]}' > artifacts.json + page=1 + while true; do + response=$(curl -s \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/actions/artifacts?per_page=100&page=$page") + + # Check if request was successful and has artifacts + artifact_count=$(echo "$response" | jq '.artifacts | length') + + if [ "$artifact_count" -eq 0 ] || [ "$artifact_count" = "null" ]; then + break + fi + + # Merge artifacts into our main file + jq -s '.[0].artifacts + .[1].artifacts | {"artifacts": .}' artifacts.json <(echo "$response") > temp.json + mv temp.json artifacts.json + + page=$((page + 1)) + + # Safety break after 10 pages (1000 artifacts) + if [ $page -gt 10 ]; then + break + fi + done - name: Check each runner heartbeat id: check