Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PHP + GitHub + Azure Functions = ?
Search
sakuragawa
February 28, 2017
Programming
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHP + GitHub + Azure Functions = ?
sakuragawa
February 28, 2017
More Decks by sakuragawa
See All by sakuragawa
CircleCI APIでプチ効率化
sakuragawa
1
600
今こそCakePHP3に乗り換えよう!/php_conference_fukuoka_2016
sakuragawa
0
1.1k
CakePHP2と3の違い
sakuragawa
8
4.9k
Other Decks in Programming
See All in Programming
ALB ログから Trace を気合で繋げる技術
fohte
7
760
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
370
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
760
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
3
2.2k
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.9k
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
390
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
私のClaude Code活用法 (個人開発編) - PHPerKaigi mini #4(2026/08/24)
panda_program
1
190
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
660
生成AIで帳票OCRが「簡単に」作れる時代になった?
kon_shou
0
1.2k
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
560
Featured
See All Featured
It's Worth the Effort
3n
188
29k
New Earth Scene 8
popppiees
3
2.5k
Building the Perfect Custom Keyboard
takai
2
850
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Designing for Timeless Needs
cassininazir
1
460
Code Review Best Practice
trishagee
74
20k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Google's AI Overviews - The New Search
badams
0
1.6k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
390
Transcript
PHP + GitHub + Azure Functions = ?
自己紹介 株式会社Fusic マネージャー 技術開発部 基盤ユニット 櫻川 幸三 https://github.com/kozo https://github.com/fusic http://qiita.com/kozo
http://qiita.com/organizations/fusic http://fusic-kiban.hatenablog.com/ 2
3 PHP?GitHub?Azure? 何をしたいの?
4
5 で、どうやって作るの?
6 実はものすごく簡単
作り方の流れ 1. GitHubアプリケーションの設定 2. OAuth認証 3. WebHookの設定 4. GitHubAPIの実行 7
GitHubアプリケーションの設定 8 [GitHub] - [Settings] - [OAuth applications] - [Register
a new application]
GitHubアプリケーションの設定 9 ※Client ID、Client Secretを控えておく
作り方の流れ 1. GitHubアプリケーションの設定 2. OAuth認証 3. WebHookの設定 4. GitHubAPIの実行 10
2. OAuth認証1 11 https://github.com/login/oauth/authorize? client_id={Client ID}&scope=repo,admin:repo_hook - client_id : アプリケーションの作成をしたときに取得したもの
- scope : 取得したい権限(複数ある場合はカンマで区切る) - repo : ソースコードへのread,write、ステータス、コメント等 - admin:repo_hook : read,write,delete等のHook用 ※scopeは最低限を設定するようにする
2. OAuth認証1 12 「Authorize application」ボタンをクリックすることで、 アプリ作成したときに入力した「callback url」に戻ってくる。
2. OAuth認証2 13 http://example.com/oauths/callback?code={コード} - code : GitHubからcallback URLにコードが戻ってくる
2. OAuth認証3 14 https://github.com/login/oauth/access_token? code={コード}& client_id={Client ID}& client_secret={Client Secret} -
code : GitHubからcallback URLに戻ってきたコード - client_id : GitHubのアプリ作成で控えておいたClinet ID - client_secret : GitHubのアプリ作成で控えておいたClient Secret URLを作成したら、file_get_contents等を利用してURLをたたくと、 AccessTokenが取得できる。 AccessTokenを利用して、GitHub APIを実行します。
15 これで準備完了
3. Web Hookの設定 16 /repos/{:owner}/{:repo}/hooks $data = [ 'name' =>
'web', "active" => true, "events" => [ "push", "pull_request" ], "config" => [ "url" => "https://gitfusic.azurewebsites.net/api/hook2", "content_type" => "json" ] ]; APIを実行して、Hookの設定を行う。 ※プルリク作成、pushしたタイミングでHookする等 JSON化してPOSTする - events : hookしたい処理 - url : hookしたときに実行されたいURL
3. GitHub APIの実行 17 /repos/{:owner}/{:repo}/statuses/{:sha} $data = [ 'state' =>
'success', "target_url" => "https://example.com/build/status", "description" => "いいコード書いたね!", "context" => "LGTM!!" ]; APIを実行することで、ステータスを切り替える。 JSON化してPOSTする - status : “pending”,“success”,“error”,“failure”のいづれかを指定 - sha : hookしたときにGitHubからPOSTで飛んでくる
3. その他API 18 /repos/{:owner}/{:repo}/issues/{:num}/comments - プルリクにコメントをつける /repos/{:owner}/{:repo}/issues/{:num}/assignees -プルリクのアサインを追加する /repos/{:owner}/{:repo}/labels /repos/{:owner}/{:repo}/issues/{:num}/labels
- ラベルの作成・追加する
3. API注意点 19 - User-Agentにアプリケーションの名前を設定する - ヘッダーにAccessTokenを設定する
他にも色々できそう - リポジトリを作成したときに、自動でラベルを 作成しておく。 - プルリク作ったタイミングで、アサインやラベ ルを自動で登録しておく。 - いいね!の数をランキングする 20
21 で、Azureはどうなん?
24 URLを作る ファイルを修正 ファイルをアップ
Azure Functions注意点 - echo等標準出力はすべてログに出力される - レスポンスを返すには以下を利用する - file_put_contents(getenv('res'), json_encode($resList)); -
リクエストを受け取るには以下を利用する - $post = file_get_contents(getenv('req')); - $_POST等は利用できない 25
ご清聴ありがとうございました Fusicはテクノロジーが 好きなエンジニアを募集しています https://fusic.github.io 26