-
Notifications
You must be signed in to change notification settings - Fork 48
/
Rakefile
executable file
·49 lines (40 loc) · 1.39 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env rake
require './fidgit.rb'
require 'toml'
desc 'Bootstrap GitHub repos'
task :bootstrap_repos do
Repository.delete_all
incoming = TOML.load_file("setup.toml")
incoming['repos'].each do |key, val|
repository = Repository.create( :name => val["name"],
:github_address => val["location"],
:figshare_article_id => val["figshare_article_id"],
:secret => val["secret"])
puts "Created #{repository.github_address} : #{repository.secret}"
end
end
desc 'Setup JSON payload to post release information to Fidgit address'
task :setup_payloads do
unless File.exists?("setup.toml")
puts "Have you set up your config yet? See setup.toml.example"
exit 1
end
incoming = TOML.load_file("setup.toml")
# GITHUB_TOKEN is instantiated in fidgit.rb
client = Octokit::Client.new(:access_token => GITHUB_TOKEN)
incoming['repos'].each do |key, val|
client.create_hook(
"#{client.user.login}/#{val["name"]}",
"web",
{
:url => "#{FIDGIT_LOCATION}/releases?secret=#{val["secret"]}",
:content_type => "json"
},
{
:events => ["release"],
:active => true
}
)
puts "Created hook for #{client.user.login}/#{val["name"]} posting to #{FIDGIT_LOCATION}/releases?secret=#{val["secret"]}"
end
end