跳至主要內容
返回技術博客

· 2 min read · ·

GitHub CLI PR events: a notification still needs a state check

GitHub CLI’s Event Streams preview can wake an agent when a PR changes. Reliable automation still needs current-state checks, commit identity, bounded waits and safe retries.

  • GitHub CLI
  • Automation
  • AI Agent
  • CI/CD
On this page
  1. What is available?
  2. Treat an event as a reason to check again
  3. Give waiting an explicit exit
  4. A retry must not become a second deployment
  5. Test the uncomfortable cases
  6. Start with a read-only workflow

Waiting for a pull request often turns into a loop of asking the same question. GitHub’s latest CLI update introduces another entry point: wait for a change, then decide what to do.

What is available?

On November 18, 2026, GitHub announced Event Streams support in CLI v2.105.0. gh event listen waits for PR changes, exits after the first event by default and supports a timeout. Both the commands and service are in preview; service access is required. See the official announcement.

The approach below is 8plus’s workflow recommendation, not a report of a production integration with this preview.

Treat an event as a reason to check again

Suppose automation is waiting for checks on commit A. A developer pushes B before a completion notification arrives. That notification alone cannot establish that the current PR is ready. Read the current head, verify which revision the required checks cover, and inspect their conclusions and the applicable merge conditions.

A submitted review also does not necessarily mean approval or that every review requirement is satisfied. Separating the wake-up signal from the decision makes the workflow easier to explain.

Give waiting an explicit exit

A conceptual sequence is:

  1. Establish a listener and confirm readiness.
  2. Read current state. If the condition already holds, stop waiting and clean up.
  3. On an event, read state again and verify the PR, commit and required conditions.
  4. Continue only within the deadline. Record and stop on timeout, lost access or connection failure.

This is a design outline, not executable CLI syntax. Listening before reading can reduce an initialization gap, but delivery, reconnection and replay behavior must be checked against service documentation and tests. Do not assume a preview guarantees that no events are lost.

A retry must not become a second deployment

Repeated notifications or restarted workers should be able to recognize an operation already completed for a revision. A work identity can include the repository, PR number, commit SHA and operation type, with a record of the successful result.

Different actions have different side effects. Publishing a message, deploying and modifying remote state cannot all be retried blindly. If the outcome is uncertain, inspect actual state before repeating the action. Existing production approvals and protections still apply.

Test the uncomfortable cases

Include a new push during the wait, a review that does not satisfy the condition, a disconnected stream and a timeout. Check that incomplete work remains explicitly incomplete.

Useful logs capture the wait’s start and end, the last verified revision, unmet conditions and the exit reason. Keep access tokens and sensitive payloads out. The next operator should know whether to wait, retry or investigate.

Start with a read-only workflow

Teams with preview access can begin with a PR status reminder, comparing request volume, waiting time and explainability of failures with their existing bounded polling. Add actions with side effects only after those behaviors are understood. Teams without access can still improve backoff, deadlines and revision checks today.

An event tells automation when to look again. The current revision and its actual conditions should determine whether work can proceed.

Related: Copilot team plugin rollout and AI agent handoffs.

SUBSCRIBE

新文章寄到你的信箱

每月約 2–4 篇,主題是 AI 導入、Web 工程與維運。只在有新文章時寄出,隨時可以退訂。

送出後會收到一封確認信,點擊確認才會開始寄送。確認信可能被歸到垃圾郵件,請留意一下。

用 RSS 訂閱

習慣用 Feedly、Inoreader 或其他閱讀器?加入這個網址即可。

https://www.8plus.app/feed.xml
開啟 RSS

想把文章裡的想法落地?

預約一場諮詢,讓我們針對你的系統與流程一起討論可行的做法。