Skip to content

Commit 22899ed

Browse files
ci: dry-run the Hacktoberfest prep tracker on push/PR (#15227)
* ci: dry-run hacktoberfest prep on push/PR, add path filters * ci: use double quotes in path filters (prettier) * fix: resolve tracker rows via /issues so issue rows don't 404 The tracker's 'Open issues' section lists issue numbers; querying them against /pulls/{n} returns 404 and crashed the whole refresh. Query the unified /issues/{n} endpoint instead, which resolves for both PRs and issues; a row is 'merged' only when it's a PR with merged_at set.
1 parent fb906d8 commit 22899ed

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

.github/workflows/hacktoberfest_prep.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
name: hacktoberfest_prep
77

88
on:
9+
push:
10+
paths:
11+
- ".github/workflows/hacktoberfest_prep.yml"
12+
- "scripts/hacktoberfest_prep_update.py"
13+
pull_request:
14+
paths:
15+
- ".github/workflows/hacktoberfest_prep.yml"
16+
- "scripts/hacktoberfest_prep_update.py"
917
schedule:
1018
- cron: "50 11 * * *" # 11:50 UTC every day
1119
workflow_dispatch: # allow a manual run while testing
@@ -37,7 +45,20 @@ jobs:
3745
set +e
3846
python scripts/hacktoberfest_prep_update.py
3947
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
48+
# Dry run on push / pull_request: show the diff the script produced but
49+
# do NOT commit or push. This lets a PR prove the tracker still gathers
50+
# its data and rewrites docs/hacktober_2026_prep.md correctly without
51+
# leaving a permanent commit. Only the schedule/manual runs persist.
52+
- name: Show changes (dry run)
53+
if: github.event_name == 'push' || github.event_name == 'pull_request'
54+
run: |
55+
echo "Dry run (${{ github.event_name }}): showing git diff, not committing."
56+
git --no-pager diff -- docs/hacktober_2026_prep.md
57+
if git diff --quiet -- docs/hacktober_2026_prep.md; then
58+
echo "No changes to docs/hacktober_2026_prep.md."
59+
fi
4060
- name: Commit any changes
61+
if: github.event_name != 'push' && github.event_name != 'pull_request'
4162
run: |
4263
git config --global user.name "$GITHUB_ACTOR"
4364
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"

scripts/hacktoberfest_prep_update.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,22 @@ async def _search_count(
113113
async def pr_state(
114114
client: httpx2.AsyncClient, sem: asyncio.Semaphore, number: int
115115
) -> str | None:
116-
"""Return ``"merged"`` / ``"closed"`` for a resolved PR, else ``None``."""
117-
body, _ = await _request(client, sem, f"{API}/repos/{REPO}/pulls/{number}")
116+
"""Return ``"merged"`` / ``"closed"`` for a resolved row, else ``None``.
117+
118+
Uses the unified ``/issues/{number}`` endpoint, which resolves for both
119+
pull requests *and* issues. The tracker's "Open issues" section lists
120+
issue numbers, and ``/pulls/{issue}`` 404s on those, so querying
121+
``/issues`` keeps a single issue row from crashing the whole run. A row is
122+
"merged" only when it is a PR whose ``pull_request.merged_at`` is set; any
123+
other closed row is "closed".
124+
"""
125+
body, _ = await _request(client, sem, f"{API}/repos/{REPO}/issues/{number}")
118126
if body.get("state") == "open": # type: ignore[union-attr]
119127
return None
120-
return "merged" if body.get("merged_at") else "closed" # type: ignore[union-attr]
128+
pr = body.get("pull_request") # type: ignore[union-attr]
129+
if pr and pr.get("merged_at"):
130+
return "merged"
131+
return "closed"
121132

122133

123134
async def top_awaiting_directories(

0 commit comments

Comments
 (0)