@kyanny's blog

My thoughts, my life. Views/opinions are my own.

gh webhook forward

GitHub CLI (gh) の拡張を入れると webhook をローカルに転送できる。ngrok の代替として使える。Webhook 転送に特化してる分、デバッグ用に便利。

Receiving webhooks with the GitHub CLI - GitHub Docs

GitHub - cli/gh-webhook

新めの gh でアクセストークンを Keychain とかに保存してると Error: you must be authenticated to run this command と出てしまって動かない問題がある。

✅ Can't use `gh webhooks forward`: "Error: you must be authenticated to run this command" - C#

"Error: you must be authenticated to run this command", despite being authenticated · Issue #11 · cli/gh-webhook · GitHub

gh-webhook 側の修正を待つまでは export GITHUB_TOKEN=xxx でアクセストークンをセットしてからやると gh webhook forward が動くようになる。

export GITHUB_TOKEN=xxx

gh webhook forward --repo=OWNER/REPO --events=issues --url=http://localhost:8080

gh webhook forward の実行中だけ、リポジトリなり organization なりに webhook が自動追加される。コマンド終了すると追加された webhook も消える。追加されてる最中に Web UI で見ると Development というラベルがついてる。Webhook の Recent Deliveries 欄で送信した webhook リクエストのログも見れる。