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
Transcript
24 slides
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
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
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
210
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
200
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
370
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
380
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1k
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
130
Getting Started with Vibe Coding
miccheng
0
240
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
2.4k
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
660
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
720
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
170
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
How STYLIGHT went responsive
nonsquared
100
6.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
450
エンジニアに許された特別な時間の終わり
watany
109
250k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
48k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
WENDY [Excerpt]
tessaabrams
15
41k
GitHub's CSS Performance
jonrohan
1033
470k