This repository has been archived by the owner on Jan 27, 2025. It is now read-only.
forked from opensourcerails/opensourcerails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
56 lines (41 loc) · 1.57 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
50
51
52
53
54
55
56
require 'rubygems'
PROJECT_ROOT = File.expand_path("../", __FILE__)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('./Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'active_support/all'
desc "Generate data/github.yml by reading all the projects and querying github for them"
task :github_data do
# read existing file and see if we need to refetch it
# TODO
require 'octokit'
puts "Generating Github data..."
Octokit.netrc = true
github_data = {}
project_data = YAML.load_file("#{PROJECT_ROOT}/data/projects.yml")
project_data.to_a.each do |project|
next if project["github_project"].blank?
begin
# TODO: only write the keys we're going to use
github_data[project["id"]] = Octokit.repo(project["github_project"]).to_hash
rescue Octokit::NotFound => e
puts "Unable to find github project for: #{project['github_project']}"
end
end
# write to file
yaml_data = "# GITHUB DATA GENERATED: #{Time.now.strftime('%B %d, %Y %I:%m%P')}\n\n"+github_data.to_yaml(:Indent => 2, :UseHeader => false)
File.open("#{PROJECT_ROOT}/data/github.yml", 'w') {|f| f.write(yaml_data) }
puts "Generating Github data complete. Data written to #{PROJECT_ROOT}/data/github.yml"
end
desc "Deploy project"
task :deploy do
puts "Deploying"
# first regenerate github data
Rake::Task["github_data"].invoke
system("middleman build --verbose")
system("divshot push")
# slack notification
# TODO: (data/slack.yml)
# run deploy command
# show a growl alert afterwards
end