Skip to content

Commit b9d7288

Browse files
author
Hubot
committed
Sync changes from upstream repository
1 parent be7e606 commit b9d7288

3 files changed

Lines changed: 58 additions & 6 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: New webhook event actions are coming
3+
author_name: davidcelis
4+
---
5+
6+
We will soon begin introducing new `action` values for several existing webhook events. If you currently subscribe to webhooks but do not check the payload's `action` value, you may end up incorrectly processing events after this change is released. To ensure that your webhook processing is not affected by these new `action` values, **you should audit your webhook processing logic by April 15th, 2016**.
7+
8+
We are providing an advance notice to warn of these changes. In the future, we may continue adding new actions without providing further warning.
9+
10+
### A brief overview of GitHub webhook actions
11+
12+
Webhook events can have multiple actions. For example, the [`IssuesEvent`](https://developer.github.com/v3/activity/events/types/#issuesevent) has several possible actions. These include `opened` when the issue is created, `closed` when the issue is closed, and `assigned` when the issue is assigned to someone. Historically, we haven't added new actions to webhook events that have only one action. However, as GitHub's feature set grows, we may occasionally add new actions to existing event types. We encourage you to take some time and ensure that your application explicitly checks the action before doing any processing.
13+
14+
### What to avoid when working with event actions
15+
16+
Here's an example of functionality that **will not work** when attempting to process an `IssuesEvent`. In this example, the `process_closed` method will be called for any event action which is not `opened` or `assigned`. This means that the `process_closed` method will be called for events with the `closed` action, but also other events with actions other than `opened` or `assigned` that are delivered to the webhook.
17+
18+
```ruby
19+
# The following is not future-proof!
20+
case action
21+
when "opened"
22+
process_opened
23+
when "assigned"
24+
process_assigned
25+
else
26+
process_closed
27+
end
28+
```
29+
30+
### How to work with new event actions
31+
32+
We suggest that you explicitly check event actions and act accordingly. In this example, the `closed` action is checked first before calling the `process_closed` method. Additionally, for unknown actions, we log that something new was encountered:
33+
34+
```ruby
35+
# The following is recommended
36+
case action
37+
when "opened"
38+
process_opened
39+
when "assigned"
40+
process_assigned
41+
when "closed"
42+
process_closed
43+
else
44+
puts "Ooohh, something new from GitHub!"
45+
end
46+
```
47+
48+
We may also add new webhook event types from time to time. If your webhook is configured to "Send me **everything**", your code should also explicitly check for the event type in a similar way as we have done with checking for the action type above. Take a look at our [integrators best practices guide][best-practices] for more tips.
49+
50+
If you have any questions or feedback, please [get in touch][get-in-touch].
51+
52+
[best-practices]: https://developer.github.com/guides/best-practices-for-integrators/
53+
[get-in-touch]: https://github.com/contact?form[subject]=New+Webhook+Actions

layouts/includes/pagination_bar.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- @count_gap refers to the minimum number of sibling pages to show -->
1+
<%# @count_gap refers to the minimum number of sibling pages to show %>
22
<% @count_gap = 2; @i = 1; @total_pages = total_pages; %>
33
<div class="pagination">
44
<% if @current_page > 1 %>
@@ -7,14 +7,13 @@
77
<span class="disabled">Previous</span>
88
<% end %>
99

10-
<!-- using a while loop here as it's the only way to skip several iterations -->
1110
<% while @i <= @total_pages do %>
1211
<% @gap = false %>
13-
<!-- first half ensures we're not caught in an infinite loop at @total_pages - 1 -->
14-
<!-- second half, with the .abs, checks for gap siblings ahead *and* behind the current page -->
12+
<%# first half ensures we're not caught in an infinite loop at @total_pages - 1 %>
13+
<%# second half, with the .abs, checks for gap siblings ahead *and* behind the current page %>
1514
<% if @i < (@total_pages - 1) && (@i - @current_page).abs > @count_gap %>
1615
<% @gap = true %>
17-
<!-- we skip multiple iterations to insert the gap (`...`), and continue with the regular links -->
16+
<%# we skip multiple iterations to insert the gap (`...`), and continue with the regular links %>
1817
<% @i = (@i < @current_page ? @current_page - @count_gap : @total_pages - 1) - 1 %>
1918
<% end %>
2019

lib/changes_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def paginated_api_changes(first, last, version = nil)
4242
end
4343

4444
def total_pages(version = nil)
45-
(api_changes(version).length / PER_PAGE).floor + 1
45+
(api_changes(version).length / PER_PAGE).floor
4646
end
4747

4848
# Public

0 commit comments

Comments
 (0)