Skip to Content
GitHubツールビルディング ―GitHub APIを活用したワークフローの拡張とカスタマイズ
book

GitHubツールビルディング ―GitHub APIを活用したワークフローの拡張とカスタマイズ

by Chris Dawson, Ben Straub, 池田 尚史, 笹井 崇司
May 2017
Intermediate to advanced
320 pages
6h 54m
Japanese
O'Reilly Japan, Inc.
Content preview from GitHubツールビルディング ―GitHub APIを活用したワークフローの拡張とカスタマイズ
203
8.4 Activity API の概要
8.4.5
 
PR
通知を
HTTP
POST
リクエストとして扱う
GitHub
から
PR
通知が到着したときの
HTTP
ハンドラーを作ろう。トップレベルスクリプトに
直接追加する、という安易な道をとりたくなるかもしれない。ところが、
JavaScript
はコールバッ
クでイベントを処理すること、そして、
Hubot
拡張は
1
つのコンストラクタしか
export
しないこ
と(
module.exports
構文を使って)を考えると、メインの拡張スクリプトから
require
される別
のモジュールを作った方が簡単だろう。何よりも、テストがやりやすくなる。
テストを書くことから始めよう。すでに
robot.router.post
の呼び出しを検証するテストはで
きている。実際に
PR
通知を処理する機能をテストしたいので、
describe
構文で新しいグループ
#pr
を追加しよう。この新しい機能は単純だ。
Hubot
が適切なパラメータ(何より重要なのは、
内部のシークレットがリクエストで送られたシークレットと一致すること)を受け取ったら、有
効な
PR
として受け入れて、指示にしたがってチャットルームにメッセージを送る。すなわち、
Pull Request
のレビューにユーザーを招待する。ハンドラーは
2
つのメソッドを公開する必要が
ある。
/pr
に対する
HTTP
リクエストの処理を任せる
prHandler
メソッドと、シークレットを設
定する
setSecret
メソッドだ。ハンドラーライブラリの内部シグネチャが決まったら ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JavaScript 第7版

JavaScript 第7版

David Flanagan, 村上 列
実践 Keycloak ―OpenID Connect、OAuth 2.0を利用したモダンアプリケーションのセキュリティー保護

実践 Keycloak ―OpenID Connect、OAuth 2.0を利用したモダンアプリケーションのセキュリティー保護

Stian Thorgersen, Pedro Igor Silva, 和田 広之, 田村 広平, 乗松 隆志, 田畑 義之
セキュアで信頼性のあるシステム構築 ―Google SREが考える安全なシステムの設計、実装、保守

セキュアで信頼性のあるシステム構築 ―Google SREが考える安全なシステムの設計、実装、保守

Heather Adkins, Betsy Beyer, Paul Blankinship, Piotr Lewandowski, Ana Oprea, Adam Stubblefield, Kuma Arakawa, 渡邉 了介

Publisher Resources

ISBN: 9784873117959Other