diff --git a/.github/workflows/refresh-forks-list.yml b/.github/workflows/refresh-forks-list.yml index 7773c07..a217e47 100644 --- a/.github/workflows/refresh-forks-list.yml +++ b/.github/workflows/refresh-forks-list.yml @@ -16,8 +16,10 @@ jobs: - name: Fetch fork data id: fetch_forks + env: + GH_TOKEN: ${{ github.token }} run: | - THIRTY_DAYS_AGO=$(date -u -d '30 days ago' +%Y-%m-%dT%H:%M:%SZ) + THIRTY_DAYS_AGO=$(date -u -d '15 days ago' +%Y-%m-%dT%H:%M:%SZ) curl -s -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/${{ github.repository }}/forks?sort=newest&per_page=100" \ @@ -31,6 +33,40 @@ jobs: created_at: .created_at, updated_at: .updated_at }]' forks.json > recent_forks.json + + # Iterate through each fork to get the latest successful run + echo "[" > runs_data.json + FIRST=true + + while IFS= read -r fork; do + OWNER=$(echo "$fork" | jq -r '.owner') + REPO=$(echo "$fork" | jq -r '.name') + CREATED=$(echo "$fork" | jq -r '.created_at') + UPDATED=$(echo "$fork" | jq -r '.updated_at') + + RUN_INFO=$(curl -s -H "Authorization: Bearer $GH_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/$OWNER/$REPO/actions/runs?per_page=1&status=success") + + RUN_TITLE=$(echo "$RUN_INFO" | jq -r '.workflow_runs[0].display_title') + RUN_URL=$(echo "$RUN_INFO" | jq -r '.workflow_runs[0].html_url') + + if [ "$FIRST" = false ]; then echo "," >> runs_data.json; fi + + jq -n \ + --arg owner "$OWNER" \ + --arg repo "$REPO" \ + --arg created "$CREATED" \ + --arg updated "$UPDATED" \ + --arg run_title "$RUN_TITLE" \ + --arg run_url "$RUN_URL" \ + '{owner: $owner, name: $repo, created_at: $created, updated_at: $updated, run_title: $run_title, run_url: $run_url}' \ + >> runs_data.json + + FIRST=false + done < <(jq -c '.[]' recent_forks.json) + + echo "]" >> runs_data.json - name: Generate Forks content run: | @@ -41,8 +77,7 @@ jobs: 1. Sign in to your GitHub account https://github.com/login 2. Browse links in the list below to find the image you need - 3. Click on a successful workflow runs (green checkmark) - 4. Scroll down to **Artifacts** section to download it + 3. Scroll down to **Artifacts** section to download it
❌ DO NOT EXPAND — contains mass unmarketable truths @@ -72,11 +107,11 @@ jobs: ## Recently Active Forks - | Recent Fork | Created | Last Activity | - |-------------|---------|---------------| + | Recent Fork | Latest Build | Created | Last Activity | + |-------------|--------------|---------|---------------| EOF - jq -r '.[] | "| [\(.owner)/\(.name)](https://github.com/\(.owner)/\(.name)/actions) | \(.created_at[:10]) | \(.updated_at[:10]) |"' recent_forks.json >> release_notes.md + jq -r '.[] | "| [\(.owner)/\(.name)](https://github.com/\(.owner)/\(.name)/actions) | [\(.run_title)](\(.run_url)) | \(.created_at[:10]) | \(.updated_at[:10]) |"' runs_data.json >> release_notes.md cat >> release_notes.md << EOF @@ -92,7 +127,7 @@ jobs: If none of the recent forks have the macOS version you need: 1. [Fork this repository](../../fork) - 2. Follow the [Usage Guide](../../#usage-guide) to build your own image + 2. Follow the [Usage guide](../../?tab=readme-ov-file#how-to-use-this) to build your own image 3. Your fork will appear here for others to benefit from! EOF