Slide 1

Slide 1 text

> sessions/workshops/ Building GitHub integrations with webhooks and REST Brooks Swinnerton Jane Sternbach John Tzikas

Slide 2

Slide 2 text

Brooks Swinnerton Engineering Manager, Ecosystem Events Jane Sternbach Senior Software Engineer, Ecosystem Events John Tzikas Senior Software Engineer, Ecosystem Events

Slide 3

Slide 3 text

Today’s agenda 1. Introduction to REST APIs
 2. Introduction to Webhooks
 3. Webhooks best practices
 4. Workshop: Building an integration

Slide 4

Slide 4 text

Today’s agenda 1. Introduction to REST APIs
 2. Introduction to Webhooks
 3. Webhooks best practices
 4. Workshop: Building an integration

Slide 5

Slide 5 text

Today’s agenda 1. Introduction to REST APIs
 2. Introduction to Webhooks
 3. Webhooks best practices
 4. Workshop: Building an integration

Slide 6

Slide 6 text

Today’s agenda 1. Introduction to REST APIs
 2. Introduction to Webhooks
 3. Webhooks best practices
 4. Workshop: Building an integration

Slide 7

Slide 7 text

Today’s agenda 1. Introduction to REST APIs
 2. Introduction to Webhooks
 3. Webhooks best practices
 4. Workshop: Building an integration

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

REST APIs

Slide 10

Slide 10 text

a way of programmatically getting data

Slide 11

Slide 11 text

HTTP Request / Response Lifecycle

Slide 12

Slide 12 text

GET https://api.github.com/user

Slide 13

Slide 13 text

GET https://api.github.com/user └─┘ verb

Slide 14

Slide 14 text

GET https://api.github.com/user └─┘ verb └───────────────┘ endpoint

Slide 15

Slide 15 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /user │ │ │e │ │───────────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ You │ │ GitHub │ │ │ │◀───────────────────────────────────│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "login": "bswinnerton", │ │ │ │ │ ... │ │ │ │ │ } │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 16

Slide 16 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /user │ │ │e │ │───────────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ You │ │ GitHub │ │ │ │◀───────────────────────────────────│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "login": "bswinnerton", │ │ │ │ │ ... │ │ │ │ │ } │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 17

Slide 17 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /user │ │ │e │ │───────────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ You │ │ GitHub │ │ │ │◀───────────────────────────────────│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "login": "bswinnerton", │ │ │ │ │ ... │ │ │ │ │ } │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 18

Slide 18 text

{ "login": "bswinnerton", "id": 934497, "name": "Brooks Swinnerton", "company": "GitHub", "blog": "https://brooks.sh", "location": "Brooklyn, NY", "bio": "Ecosystem Engineering Manager", "public_repos": 41, "public_gists": 56, "followers": 620, "following": 68, "created_at": "2011-07-23T17:44:47Z", "updated_at": "2020-04-25T00:15:50Z" } > JSON

Slide 19

Slide 19 text

how does this work in practice?

Slide 20

Slide 20 text

$ curl -X GET https://api.github.com/user

Slide 21

Slide 21 text

client libraries

Slide 22

Slide 22 text

client = Octokit::Client.new( login: 'monalisa', password: 'correcthorsebatterystaple' ) client.user

Slide 23

Slide 23 text

const { Octokit } = require("@octokit/rest"); const octokit = new Octokit(); octokit.users.getAuthenticated();

Slide 24

Slide 24 text

REST APIs are based on a “pull” model

Slide 25

Slide 25 text

it’s hard to achieve real time in this model

Slide 26

Slide 26 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /pull_requests/:id │ │ │e │ │───────────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ You │ │ GitHub │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 27

Slide 27 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /pull_requests/:id │ │ │e │ │───────────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ You │ │ GitHub │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 28

Slide 28 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /pull_requests/:id │ │ │e │ │───────────────────────────────────▶│ │ │ │ │◀───────────────────────────────────│ │ │ │ │ HTTP 304 Not Modified │ │ │ │ │ │ │ │ │ You │ │ GitHub │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 29

Slide 29 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /pull_requests/:id │ │ │e │ │───────────────────────────────────▶│ │ │ │ │◀───────────────────────────────────│ │ │ │ │ HTTP 304 Not Modified │ │ │ │ │ │ │ │ │ You │ GET /pull_requests/:id │ GitHub │ │ │ │───────────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 30

Slide 30 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /pull_requests/:id │ │ │e │ │───────────────────────────────────▶│ │ │ │ │◀───────────────────────────────────│ │ │ │ │ HTTP 304 Not Modified │ │ │ │ │ │ │ │ │ You │ GET /pull_requests/:id │ GitHub │ │ │ │───────────────────────────────────▶│ │ │ │ │◀───────────────────────────────────│ │ │ │ │ HTTP 304 Not Modified │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 31

Slide 31 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /pull_requests/:id │ │ │e │ │───────────────────────────────────▶│ │ │ │ │◀───────────────────────────────────│ │ │ │ │ HTTP 304 Not Modified │ │ │ │ │ │ │ │ │ You │ GET /pull_requests/:id │ GitHub │ │ │ │───────────────────────────────────▶│ │ │ │ │◀───────────────────────────────────│ │ │ │ │ HTTP 304 Not Modified │ │ │ │ │ │ │ │ │ │ GET /pull_requests/:id │ │ │ │ │───────────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 32

Slide 32 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /pull_requests/:id │ │ │e │ │───────────────────────────────────▶│ │ │ │ │◀───────────────────────────────────│ │ │ │ │ HTTP 304 Not Modified │ │ │ │ │ │ │ │ │ You │ GET /pull_requests/:id │ GitHub │ │ │ │───────────────────────────────────▶│ │ │ │ │◀───────────────────────────────────│ │ │ │ │ HTTP 304 Not Modified │ │ │ │ │ │ │ │ │ │ GET /pull_requests/:id │ │ │ │ │───────────────────────────────────▶│ │ │ │ │◀───────────────────────────────────│ │ │ │ │ HTTP 200 OK {...} │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 33

Slide 33 text

rate limits

Slide 34

Slide 34 text

what would a “push” model look like?

Slide 35

Slide 35 text

Webhooks

Slide 36

Slide 36 text

webhooks change the flow of data

Slide 37

Slide 37 text

┌─────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ GET /user │ │ │e │ │───────────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ You │ │ GitHub │ │ │ │◀───────────────────────────────────│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "login": "bswinnerton", │ │ │ │ │ ... │ │ │ │ │ } │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┘ └────────┘ ▼ > REST API

Slide 38

Slide 38 text

┌────────┐ ┌─────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "action": "edited", │ │ │ │ GitHub │ ... │ You │ │ │ │ } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │◀───────────────────────────────│ │ │ │ │ HTTP 200 OK │ │ │ │ │ │ │ │ └────────┘ └─────┘ ▼ > webhooks

Slide 39

Slide 39 text

┌────────┐ ┌─────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "action": "edited", │ │ │ │ GitHub │ ... │ You │ │ │ │ } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │◀───────────────────────────────│ │ │ │ │ HTTP 200 OK │ │ │ │ │ │ │ │ └────────┘ └─────┘ ▼ > webhooks

Slide 40

Slide 40 text

┌────────┐ ┌─────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "action": "edited", │ │ │ │ GitHub │ ... │ You │ │ │ │ } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │◀───────────────────────────────│ │ │ │ │ HTTP 200 OK │ │ │ │ │ │ │ │ └────────┘ └─────┘ ▼ > webhooks

Slide 41

Slide 41 text

anatomy of a webhook

Slide 42

Slide 42 text

HTTP/1.1 User-Agent: GitHub-Hookshot/ef5a70a X-Github-Delivery: d6552d80-8a73-11ea-83d4-d009fa985176 X-Github-Event: issue_comment { "action": "created", "comment": { "id": 621527989, "body": "Hi Mom” ... }, "sender": { "login": “bswinnerton", ... } ... }

Slide 43

Slide 43 text

HTTP/1.1 User-Agent: GitHub-Hookshot/ef5a70a X-Github-Delivery: d6552d80-8a73-11ea-83d4-d009fa985176 X-Github-Event: issue_comment { "action": "created", "comment": { "id": 621527989, "body": "Hi Mom” ... }, "sender": { "login": “bswinnerton", ... } ... }

Slide 44

Slide 44 text

HTTP/1.1 User-Agent: GitHub-Hookshot/ef5a70a X-Github-Delivery: d6552d80-8a73-11ea-83d4-d009fa985176 X-Github-Event: issue_comment { "action": "created", "comment": { "id": 621527989, "body": "Hi Mom” ... }, "sender": { "login": “bswinnerton", ... } ... }

Slide 45

Slide 45 text

HTTP/1.1 User-Agent: GitHub-Hookshot/ef5a70a X-Github-Delivery: d6552d80-8a73-11ea-83d4-d009fa985176 X-Github-Event: issue_comment { "action": "created", "comment": { "id": 621527989, "body": "Hi Mom” ... }, "sender": { "login": “bswinnerton", ... } ... }

Slide 46

Slide 46 text

HTTP/1.1 User-Agent: GitHub-Hookshot/ef5a70a X-Github-Delivery: d6552d80-8a73-11ea-83d4-d009fa985176 X-Github-Event: issue_comment { "action": "created", "comment": { "id": 621527989, "body": "Hi Mom" ... }, "sender": { "login": "bswinnerton", ... } ... }

Slide 47

Slide 47 text

events & actions

Slide 48

Slide 48 text

check_run check_suite commit_comment content_reference create delete deploy_key deployment deployment_status fork github_app_authorization gollum installation installation_repositories issue_comment issues label marketplace_purchase member membership meta milestone organization org_block page_build project_card project_column project public pull_request pull_request_review pull_request_review_comment push package release repository repository_import repository_vulnerability_alert security_advisory sponsorship star status team team_add watch * > developer.github.com/webhooks/

Slide 49

Slide 49 text

check_run check_suite commit_comment content_reference create delete deploy_key deployment deployment_status fork github_app_authorization gollum installation installation_repositories issue_comment issues label marketplace_purchase member membership meta milestone organization org_block page_build project_card project_column project public pull_request pull_request_review pull_request_review_comment push package release repository repository_import repository_vulnerability_alert security_advisory sponsorship star status team team_add watch * > developer.github.com/webhooks/

Slide 50

Slide 50 text

check_run check_suite commit_comment content_reference create delete deploy_key deployment deployment_status fork github_app_authorization gollum installation installation_repositories issue_comment issues label marketplace_purchase member membership meta milestone organization org_block page_build project_card project_column project public pull_request pull_request_review pull_request_review_comment push package release repository repository_import repository_vulnerability_alert security_advisory sponsorship star status team team_add watch * > developer.github.com/webhooks/

Slide 51

Slide 51 text

check_run check_suite commit_comment content_reference create delete deploy_key deployment deployment_status fork github_app_authorization gollum installation installation_repositories issue_comment issues label marketplace_purchase member membership meta milestone organization org_block page_build project_card project_column project public pull_request pull_request_review pull_request_review_comment push package release repository repository_import repository_vulnerability_alert security_advisory sponsorship star status team team_add watch * > developer.github.com/webhooks/

Slide 52

Slide 52 text

installation targets

Slide 53

Slide 53 text

configuring a webhook

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

requirements

Slide 57

Slide 57 text

1. A web server that’s listening for requests

Slide 58

Slide 58 text

2. An address on the internet that GitHub can reach

Slide 59

Slide 59 text

ngrok

Slide 60

Slide 60 text

┌────────┐ ┌─────┐ ┌─────┐ │T │ │ │ │ │ │ │i │ │ │ │ │ │ │m │ │ POST / │ │ POST / │ │ │e │ │────────────▶│ │────────────▶│ │ │ │ │ { ... } │ │ { ... } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ GitHub │ │ngrok│ │ You │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │◀────────────│ │◀────────────│ │ │ │ │ HTTP 200 OK │ │ HTTP 200 OK │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────┘ └─────┘ └─────┘ ▼ > ngrok

Slide 61

Slide 61 text

> ngrok ┌────────┐ ┌─────┐ ┌─────┐ │T │ │ │ │ │ │ │i │ │ │ │ │ │ │m │ │ POST / │ │ POST / │ │ │e │ │────────────▶│ │────────────▶│ │ │ │ │ { ... } │ │ { ... } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ GitHub │ │ngrok│ │ You │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │◀────────────│ │◀────────────│ │ │ │ │ HTTP 200 OK │ │ HTTP 200 OK │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────┘ └─────┘ └─────┘ ▼

Slide 62

Slide 62 text

> ngrok ┌────────┐ ┌─────┐ ┌─────┐ │T │ │ │ │ │ │ │i │ │ │ │ │ │ │m │ │ POST / │ │ POST / │ │ │e │ │────────────▶│ │────────────▶│ │ │ │ │ { ... } │ │ { ... } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ GitHub │ │ngrok│ │ You │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │◀────────────│ │◀────────────│ │ │ │ │ HTTP 200 OK │ │ HTTP 200 OK │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────┘ └─────┘ └─────┘ ▼

Slide 63

Slide 63 text

Best Practices for Receiving Webhooks

Slide 64

Slide 64 text

Resiliency Security HTTP

Slide 65

Slide 65 text

Resiliency Security HTTP

Slide 66

Slide 66 text

respond to webhooks as quick as you can

Slide 67

Slide 67 text

10 second timeout

Slide 68

Slide 68 text

┌────────┐ ┌─────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ GitHub │ │ You │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────┘ └─────┘ ▼ > webhooks

Slide 69

Slide 69 text

┌────────┐ ┌─────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │────────────────────────────▶ │ │ │ │ │ │ │ │ │ │ │ │ │ │ GitHub │ │ You │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────┘ └─────┘ ▼ > webhooks

Slide 70

Slide 70 text

┌────────┐ ┌─────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │────────────────────────────▶ │ │ │ │ │─────────────────────────▶ │ │ │ │ │ │ │ │ │ GitHub │ │ You │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────┘ └─────┘ ▼ > webhooks

Slide 71

Slide 71 text

order of events is best effort

Slide 72

Slide 72 text

Resiliency Security HTTP

Slide 73

Slide 73 text


 verify authenticity with HMAC signatures

Slide 74

Slide 74 text

┌────────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "action": "edited", │ │ │ │ GitHub │ ... │ You │ │ │ │ } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │◀───────────────────────────────│ │ │ │ │ HTTP 200 OK │ │ │ │ │ │ │ │ └────────┘ └────────┘ ▼ > webhooks

Slide 75

Slide 75 text

┌────────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "action": "edited", │ │ │ │ Evil │ ... │ You │ │ │ Person │ } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │◀───────────────────────────────│ │ │ │ │ HTTP 200 OK │ │ │ │ │ │ │ │ └────────┘ └────────┘ ▼ > malicious webhooks

Slide 76

Slide 76 text

┌────────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ │ │ │ │ │ { │ │ │ │ │ "action": "edited", │ │ │ │ Evil │ ... │ You │ │ │ Person │ } │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │◀───────────────────────────────│ │ │ │ │ HTTP 200 OK │ │ │ │ │ │ │ │ └────────┘ └────────┘ ▼ > malicious webhooks

Slide 77

Slide 77 text

┌────────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ GitHub │ │ You │ │ │ │ │ │ │ │(secret)│ │(secret)│ │ │(abcdef)│ │(abcdef)│ │ │ │ │ │ │ │ │ │ │ │ │ │◀───────────────────────────────│ │ │ │ │ HTTP 200 OK │ │ │ │ │ │ │ │ └────────┘ └────────┘ ▼ > shared secret

Slide 78

Slide 78 text

┌────────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ x-hub-signature: f0ad5b │ │ │ │ │ │ │ │ │ │ { │ │ │ │ GitHub │ "action": "edited", │ You │ │ │ │ ... │ │ │ │(secret)│ } │(secret)│ │ │(abcdef)│ │(abcdef)│ │ │ │ │ │ │ │ │ │ │ │ │ │◀───────────────────────────────│ │ │ │ │ HTTP 200 OK │ │ │ │ │ │ │ │ └────────┘ └────────┘ ▼ > HMAC signatures

Slide 79

Slide 79 text

┌────────┐ ┌────────┐ │T │ │ │ │ │i │ │ │ │ │m │ │ POST / │ │ │e │ │───────────────────────────────▶│ │ │ │ │ x-hub-signature: f0ad5b ✔ │ │ │ │ │ │ │ │ │ │ { │ │ │ │ GitHub │ "action": "edited", ✔ │ You │ │ │ │ ... │ │ │ │(secret)│ } │(secret)│ │ │(abcdef)│ │(abcdef)│ │ │ │ │ │ │ │ │ │ │ │ │ │◀───────────────────────────────│ │ │ │ │ HTTP 200 OK │ │ │ │ │ │ │ │ └────────┘ └────────┘ ▼ > HMAC signatures

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

IP whitelist

Slide 82

Slide 82 text

$ curl https://api.github.com/meta

Slide 83

Slide 83 text

Resiliency Security HTTP

Slide 84

Slide 84 text

use sensible HTTP status codes

Slide 85

Slide 85 text

2xx: success 4xx: client error 5xx: server error

Slide 86

Slide 86 text

No content

Slide 87

Slide 87 text

send GitHub helpful error messages for debugging

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

keep track of GUIDs

Slide 90

Slide 90 text

HTTP/1.1 User-Agent: GitHub-Hookshot/ef5a70a X-Github-Delivery: d6552d80-8a73-11ea-83d4-d009fa985176 X-Github-Event: issue_comment { "action": "created", "comment": { "id": 621527989, "body": "Hi Mom” ... }, "sender": { "login": “bswinnerton", ... } ... }

Slide 91

Slide 91 text

tools

Slide 92

Slide 92 text

• As well as Insomnia & Paw postman

Slide 93

Slide 93 text

curl + jq $ curl -s https://api.github.com/meta | jq .hooks[0] "192.30.252.0/22"

Slide 94

Slide 94 text

• As well as requestbin and hookbin ngrok

Slide 95

Slide 95 text

Workshop

Slide 96

Slide 96 text

• Auto-updating changelog • Hosted on GitHub Pages Today’s goal

Slide 97

Slide 97 text

• How to develop & test hooks • How to make REST API calls via Octokit • Best practices with webhooks What to expect

Slide 98

Slide 98 text

• Terminal • Editor • Docker • Browser • Your repository • GitHub pages site • Webhook deliveries page Preparation

Slide 99

Slide 99 text

Workshop