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
610
今こそCakePHP3に乗り換えよう!/php_conference_fukuoka_2016
sakuragawa
0
1.2k
CakePHP2と3の違い
sakuragawa
8
4.9k
Other Decks in Programming
See All in Programming
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
1.5k
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
810
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
130
Simple Storage Service(S3) is not simple
iwatsukayura
0
330
AmebaブログはKMPから卒業します
kmars0605
0
240
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
200
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
1
200
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
0
150
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
220
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
280
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
140
Featured
See All Featured
Writing Fast Ruby
sferik
630
63k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
460
Crafting Experiences
bethany
1
390
Code Reviewing Like a Champion
maltzj
529
40k
Leo the Paperboy
mayatellez
10
2.4k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
A designer walks into a library…
pauljervisheath
211
25k
Raft: Consensus for Rubyists
vanstee
143
7.8k
The Invisible Side of Design
smashingmag
301
52k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
450
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