@@ -48,6 +48,7 @@ imports:
4848
4949steps :
5050 - name : Find a PR that needs attention
51+ id : find-pr
5152 env :
5253 GITHUB_TOKEN : ${{ github.token }}
5354 GITHUB_REPOSITORY : ${{ github.repository }}
@@ -57,6 +58,14 @@ steps:
5758 import os, json, re, subprocess, sys
5859 import urllib.request, urllib.error
5960
61+ def emit_selected_output(pr_number):
62+ """Expose `selected` as a step output for workflow gating.
63+ Empty string means no PR needs attention; otherwise the PR number."""
64+ gh_output = os.environ.get("GITHUB_OUTPUT")
65+ if gh_output:
66+ with open(gh_output, "a") as f:
67+ f.write(f"selected={'' if pr_number is None else pr_number}\n")
68+
6069 token = os.environ.get("GITHUB_TOKEN", "")
6170 repo = os.environ.get("GITHUB_REPOSITORY", "")
6271 forced_pr = os.environ.get("FORCED_PR", "").strip()
@@ -182,6 +191,7 @@ steps:
182191 print("No open PRs. Nothing to do.")
183192 with open(output_file, "w") as f:
184193 json.dump({"selected": None, "reason": "no_open_prs"}, f)
194+ emit_selected_output(None)
185195 sys.exit(0)
186196
187197 # Evaluate each PR deterministically (sorted by PR number ascending)
@@ -256,8 +266,10 @@ steps:
256266 print(f"\n>>> Selected PR #{selected['pr_number']}: {selected['title']}")
257267 print(f" Issues: {selected['issues']}")
258268 print(f" Attempt: {selected['attempts'] + 1}/{MAX_ATTEMPTS}")
269+ emit_selected_output(selected["pr_number"])
259270 else:
260271 print("\nNo PRs need attention. Nothing to do.")
272+ emit_selected_output(None)
261273 sys.exit(0)
262274 PYEOF
263275
0 commit comments