Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PHP + GitHub + Azure Functions = ?
Search
sakuragawa
February 28, 2017
Programming
270
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.2k
CakePHP2と3の違い
sakuragawa
8
4.9k
Other Decks in Programming
See All in Programming
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
570
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
110
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.8k
Verilogで学ぶCPU自作入門.pdf
uyuki234
8
3.9k
AWSに止められる覚悟してますか?
morizo_1984
2
500
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
120
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
330
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
160
iOSDC2026登壇資料.pdf
riofujimon
0
200
setup-vp GitLab対応の裏側
naokihaba
0
150
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
410
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
560
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
How to make the Groovebox
asonas
2
2.5k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
550
Fireside Chat
paigeccino
43
4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
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