├── Procfile ├── config.ru ├── Gemfile ├── views └── index.erb ├── .gitignore ├── README.md ├── test.rb ├── Gemfile.lock └── upload.rb /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec ruby upload.rb -p $PORT 2 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | require './upload' 2 | run Sinatra::Application 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | gem 'fileutils' 4 | gem 'sinatra' 5 | gem 'thin' 6 | gem 'rake' 7 | 8 | gem 'rack-test' 9 | 10 | gem 'execjs' -------------------------------------------------------------------------------- /views/index.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Ember.js uploader

4 | 5 | Fork me on GitHub 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .github-token 2 | .DS_Store 3 | 4 | *.gem 5 | *.rbc 6 | .bundle 7 | .config 8 | coverage 9 | InstalledFiles 10 | lib/bundler/man 11 | pkg 12 | rdoc 13 | spec/reports 14 | test/tmp 15 | test/version_tmp 16 | tmp 17 | 18 | # YARD artifacts 19 | .yardoc 20 | _yardoc 21 | doc/ 22 | 23 | # test artifacts 24 | vendor -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | github-uploader 2 | =============== 3 | 4 | Uploads latest build of Ember.js to the specified repository. 5 | 6 | # Installation 7 | 8 | * `git clone git@github.com:pangratz/github-uploader.git` 9 | * `cd github-uploader` 10 | 11 | * `heroku login` 12 | * `heroku create GH-UPLOADER --stack cedar` 13 | * `heroku config:add GH_OAUTH_TOKEN=""` 14 | * `git push heroku master` 15 | 16 | `GH_OAUTH_TOKEN` is the OAUTH_TOKEN, see http://developer.github.com/v3/oauth/#create-a-new-authorization 17 | 18 | # Usage 19 | 20 | POST to http://GH-UPLOADER.herokuapp.com/upload/ember.js which triggers the uploading of latest build of Ember.js 21 | 22 | # Test 23 | 24 | OAuth token is expected to be placed in `.github-token` file. 25 | 26 | `ruby test.rb` -------------------------------------------------------------------------------- /test.rb: -------------------------------------------------------------------------------- 1 | require './upload' 2 | 3 | require 'test/unit' 4 | require 'rack/test' 5 | 6 | ENV['RACK_ENV'] = 'test' 7 | 8 | class UploadTest < Test::Unit::TestCase 9 | include Rack::Test::Methods 10 | 11 | def app 12 | Sinatra::Application 13 | end 14 | 15 | def setup 16 | ENV['GH_USERNAME'] = `git config github.user`.chomp 17 | ENV['GH_REPO'] = "github-uploader" 18 | if File.exist?(".github-token") 19 | token = IO.read(".github-token") 20 | ENV['GH_OAUTH_TOKEN'] = token.strip! 21 | end 22 | end 23 | 24 | def test_upload_ember_url 25 | post '/upload/ember.js' 26 | assert last_response.ok?, "response is 200" 27 | end 28 | 29 | def test_upload_data_url 30 | post '/upload/data' 31 | assert last_response.ok?, "response is 200" 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | daemons (1.1.8) 5 | eventmachine (0.12.10) 6 | execjs (1.4.0) 7 | multi_json (~> 1.0) 8 | fileutils (0.7) 9 | rmagick (>= 2.13.1) 10 | multi_json (1.3.6) 11 | rack (1.4.1) 12 | rack-protection (1.2.0) 13 | rack 14 | rack-test (0.6.1) 15 | rack (>= 1.0) 16 | rake (0.9.2.2) 17 | rmagick (2.13.1) 18 | sinatra (1.3.2) 19 | rack (~> 1.3, >= 1.3.6) 20 | rack-protection (~> 1.2) 21 | tilt (~> 1.3, >= 1.3.3) 22 | thin (1.3.1) 23 | daemons (>= 1.0.9) 24 | eventmachine (>= 0.12.6) 25 | rack (>= 1.0.0) 26 | tilt (1.3.3) 27 | 28 | PLATFORMS 29 | ruby 30 | 31 | DEPENDENCIES 32 | execjs 33 | fileutils 34 | rack-test 35 | rake 36 | sinatra 37 | thin 38 | -------------------------------------------------------------------------------- /upload.rb: -------------------------------------------------------------------------------- 1 | require 'sinatra' 2 | require 'fileutils' 3 | require "bundler" 4 | 5 | helpers do 6 | def upload_latest(repo_name = "ember.js") 7 | root = ENV['RAILS_ROOT'] || "" 8 | dir = "#{root}/tmp/tmp_#{Process.pid}/#{repo_name}" 9 | FileUtils.rm_rf "#{dir}" 10 | 11 | url = "https://github.com/emberjs/#{repo_name}.git" 12 | puts "executing 'rake upload_latest' for #{url}" 13 | 14 | system "git clone #{url} #{dir}" 15 | Dir.chdir dir do 16 | Bundler.with_clean_env do 17 | ENV["PATH"] = "/app/bin:#{ENV["PATH"]}" 18 | # Because Heroku installs the app with "--without development", 19 | # this option is remembered by Bundler and Ember.js needs the gems 20 | # defined in this group, we are using the option "--wihtout WATWAT" 21 | # to overwrite the defined Heroku option: using "--without ''" doesn't 22 | # seem to work :( 23 | system "bundle install --without WATWAT" 24 | system "bundle exec rake upload_latest" 25 | end 26 | end 27 | end 28 | end 29 | 30 | get '/' do 31 | erb :index 32 | end 33 | 34 | post '/upload/:repo_name' do 35 | upload_latest(params[:repo_name]) 36 | end --------------------------------------------------------------------------------