now
[from now] 2013年 10月 14日 月曜日 03:25:03 JST

diff --git a/.travis.yml b/.travis.yml
index 42985cd..3d2de00 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,4 +24,4 @@ env:
   global:
     secure: P+JTmnP2htDTPuJKK/4MFJi7YNgVXNvNcyjOnHQab1txb55gELj4h+J08y3ZausY/BNaR9lbCPptjJhb9bzwcz8KdoHkdTNu7cde4qw5er+9X2RjYU/svRuGPZ4ubyWnSU+WX/HlUz89Kn8AF2XPNdTN21JotFx+FIxwpJUt/lI=
 after_success:
-  - script/after_success.sh
+  - bundle exec rails runner script/merge_pullreq_of_owner.rb
diff --git a/Gemfile b/Gemfile
index 4b1b14d..94c0597 100644
--- a/Gemfile
+++ b/Gemfile
@@ -57,6 +57,7 @@ group :development, :test do
   gem "factory_girl_rails"
   gem 'spring'
   gem 'guard-rspec'
+  gem 'octokit', require: false

   gem 'sqlite3'
 end
diff --git a/Gemfile.lock b/Gemfile.lock
index 0f34e02..8b448cc 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -35,6 +35,7 @@ GEM
       multi_json (~> 1.3)
       thread_safe (~> 0.1)
       tzinfo (~> 0.3.37)
+    addressable (2.3.5)
     arel (4.0.0)
     atomic (1.1.14)
     bcrypt-ruby (3.1.2)
@@ -71,6 +72,8 @@ GEM
     factory_girl_rails (4.2.1)
       factory_girl (~> 4.2.0)
       railties (>= 3.0.0)
+    faraday (0.8.8)
+      multipart-post (~> 1.2.0)
     ffi (1.9.0)
     formatador (0.2.4)
     fssm (0.2.10)
@@ -116,9 +119,12 @@ GEM
     mini_portile (0.5.1)
     minitest (4.7.5)
     multi_json (1.8.0)
+    multipart-post (1.2.0)
     nokogiri (1.6.0)
       mini_portile (~> 0.5.0)
     oauth (0.4.7)
+    octokit (2.4.0)
+      sawyer (~> 0.5.1)
     omniauth (1.1.4)
       hashie (>= 1.2, < 3)
       rack
@@ -193,6 +199,9 @@ GEM
       railties (>= 4.0.0.beta, < 5.0)
       sass (>= 3.1.10)
       sprockets-rails (~> 2.0.0)
+    sawyer (0.5.1)
+      addressable (~> 2.3.5)
+      faraday (~> 0.8, < 0.10)
     sdoc (0.3.20)
       json (>= 1.1.3)
       rdoc (~> 3.10)
@@ -244,6 +253,7 @@ DEPENDENCIES
   jquery-rails
   kaminari
   nokogiri
+  octokit
   omniauth-twitter
   pg
   pry-doc
diff --git a/script/after_success.sh b/script/after_success.sh
new file mode 100644
index 0000000..13f4793
--- /dev/null
+++ b/script/after_success.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+
diff --git a/script/merge_pullreq_of_owner.rb b/script/merge_pullreq_of_owner.rb
new file mode 100644
index 0000000..d280e21
--- /dev/null
+++ b/script/merge_pullreq_of_owner.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/ruby
+require 'octokit'
+
+def pull_request?
+  ENV['TRAVIS_PULL_REQUEST'] != 'false'
+end
+
+def owner_name
+  ENV['TRAVIS_REPO_SLUG'].split('/')[0]
+end
+
+def owner?(pull_requst)
+  pull_requst.user.login == owner_name
+end
+
+if pull_request?
+  client = Octokit::Client.new(access_token: ENV['GITHUB_OAUTH_TOKEN'])
+  pull_req = client.pull_request(ENV['TRAVIS_REPO_SLUG'], ENV['TRAVIS_PULL_REQUEST'])
+  if owner?(pull_req)
+    puts "ok"
+    # client.merge_pull_request(ENV['TRAVIS_REPO_SLUG'], ENV['TRAVIS_PULL_REQUEST'])
+  end
+end
[from now] 2013年 10月 14日 月曜日 03:25:13 JST

diff --git a/script/after_success.sh b/script/after_success.sh
deleted file mode 100644
index 13f4793..0000000
--- a/script/after_success.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-