Skip to content

Instantly share code, notes, and snippets.

@BenV
Forked from ysbaddaden/Gemfile
Last active August 29, 2015 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenV/cac41b36296cd9f28050 to your computer and use it in GitHub Desktop.
Save BenV/cac41b36296cd9f28050 to your computer and use it in GitHub Desktop.
Magnum Status Repeater
require "./server"
run MagnumCIGitHubIntegration
source 'https://rubygems.org'
gem "json"
gem 'sinatra', "~> 1.3.5"
gem "octokit", "~> 3.0"
GEM
remote: https://rubygems.org/
specs:
addressable (2.3.7)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
json (1.8.2)
multipart-post (2.0.0)
octokit (3.8.0)
sawyer (~> 0.6.0, >= 0.5.3)
rack (1.6.0)
rack-protection (1.5.3)
rack
sawyer (0.6.0)
addressable (~> 2.3.5)
faraday (~> 0.8, < 0.10)
sinatra (1.3.6)
rack (~> 1.4)
rack-protection (~> 1.3)
tilt (~> 1.3, >= 1.3.3)
tilt (1.4.1)
PLATFORMS
ruby
DEPENDENCIES
json
octokit (~> 3.0)
sinatra (~> 1.3.5)
require "json"
require "sinatra"
require "octokit"
class MagnumCIGitHubIntegration < Sinatra::Base
post "/post_event/:github_token" do |github_token|
return unless github_token && params[:payload]
@payload = JSON.parse(params[:payload])
@github = Octokit::Client.new(access_token: github_token)
repo = (@payload["commit_url"] =~ %r(github\.com/(.+?/.+?)/) and $1)
status = case @payload["status"]
when "pass" then "success"
when "fail" then "failure"
end
@github.create_status(repo, @payload["commit"], status,
accept: "application/vnd.github.she-hulk-preview+json",
context: "continuous-integration/magnum-ci",
description: @payload["title"],
target_url: @payload["build_url"]
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment