Skip to content

Commit f2b6bd1

Browse files
authored
fix(ci): find the last IndexNow submission through its check run, not the run's job list (#9384)
The indexnow job resolved its diff base by listing each earlier main run's jobs at 100 per page, and GitHub's jobs API answers that page with HTTP 502 for every re-run workflow run. The first release scanned back to such a run and failed the step, so no submission ever recorded a success and every later run would fail the same way. Look up the one `indexnow` check run per commit instead (small, and it counts every attempt), treat a lookup that errors as no success, and when no success is in view diff from the oldest run in view so URLs no submission ever covered are still sent.
1 parent e375abb commit f2b6bd1

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ jobs:
657657
permissions:
658658
contents: read
659659
actions: read
660+
checks: read
660661
steps:
661662
- name: Checkout code
662663
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
@@ -666,27 +667,31 @@ jobs:
666667
with:
667668
bun-version: 1.4.4
668669

669-
# Diff from the head of the last earlier run whose submission succeeded, not the previous
670+
# Diff from the last earlier main commit whose `indexnow` check succeeded, not the previous
670671
# push: a push that never deployed, or whose submission failed, would otherwise drop its
671-
# changed URLs for good. Falls back to the previous push when no such run is in view. The
672-
# diff needs only the two trees, so that one commit is fetched alone; an all-zero `before`
673-
# (the branch's first push) has no base, which the script skips.
672+
# changed URLs for good. The check-runs lookup asks for this one check per commit, so it
673+
# stays small and counts every attempt of a re-run; a lookup that errors counts as no
674+
# success. With no success in view, the base is the oldest run in view, so URLs that no
675+
# submission ever covered are sent now. The diff needs only the two trees, so that one
676+
# commit is fetched alone; an all-zero `before` (the branch's first push) has no base,
677+
# which the script skips.
674678
- name: Submit changed URLs to IndexNow
675679
env:
676680
GH_TOKEN: ${{ github.token }}
677681
PUSH_BEFORE: ${{ github.event.before }}
678682
run: |
679683
BASE_SHA=""
680-
while read -r run_id head_sha; do
681-
conclusion="$(gh api --paginate "repos/$GITHUB_REPOSITORY/actions/runs/$run_id/jobs?per_page=100" \
682-
--jq '.jobs[] | select(.name == "indexnow") | .conclusion')"
683-
if [[ "$conclusion" == "success" ]]; then
684+
OLDEST_SHA=""
685+
while read -r head_sha; do
686+
OLDEST_SHA="$head_sha"
687+
if succeeded="$(gh api "repos/$GITHUB_REPOSITORY/commits/$head_sha/check-runs?check_name=indexnow&filter=all" \
688+
--jq '[.check_runs[] | select(.conclusion == "success")] | length')" && [[ "$succeeded" -gt 0 ]]; then
684689
BASE_SHA="$head_sha"
685690
break
686691
fi
687692
done < <(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?branch=main&event=push&per_page=30" \
688-
--jq ".workflow_runs[] | select(.id < $GITHUB_RUN_ID) | \"\\(.id) \\(.head_sha)\"")
689-
BASE_SHA="${BASE_SHA:-$PUSH_BEFORE}"
693+
--jq ".workflow_runs[] | select(.id < $GITHUB_RUN_ID) | .head_sha")
694+
BASE_SHA="${BASE_SHA:-${OLDEST_SHA:-$PUSH_BEFORE}}"
690695
echo "Submitting URLs changed in $BASE_SHA..$GITHUB_SHA"
691696
if [[ ! "$BASE_SHA" =~ ^0+$ ]]; then
692697
git fetch --no-tags --depth=1 origin "$BASE_SHA"

0 commit comments

Comments
 (0)