mirror of
https://github.com/zhigang1992/boxen.git
synced 2026-01-12 22:46:11 +08:00
42 lines
1006 B
Ruby
Executable File
42 lines
1006 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# Make sure all boxen/puppet-* repos are cloned under ./puppet.
|
|
|
|
require "fileutils"
|
|
require "pathname"
|
|
|
|
# Put us where we belong, in the root dir of boxen.
|
|
|
|
Dir.chdir Pathname.new(__FILE__).realpath + "../.."
|
|
|
|
# Load the local env in case creds are set there.
|
|
|
|
load ".env.local.rb" if File.file? ".env.local.rb"
|
|
|
|
# Make sure we're up to date.
|
|
|
|
abort "Bootstrap failed." unless system "script/bootstrap"
|
|
|
|
require "bundler/setup"
|
|
require "octokit"
|
|
|
|
unless ENV["GITHUB_LOGIN"] && ENV["GITHUB_PASSWORD"]
|
|
abort "Please set the GITHUB_LOGIN and GITHUB_PASSWORD env vars."
|
|
end
|
|
|
|
api = Octokit::Client.new \
|
|
:login => ENV["GITHUB_LOGIN"], :password => ENV["GITHUB_PASSWORD"]
|
|
|
|
# Gotta have a ./puppet dir.
|
|
|
|
FileUtils.mkdir_p "puppet"
|
|
|
|
# Clone boxen/puppet-* unless we have it already.
|
|
|
|
api.organization_repositories("boxen").each do |repo|
|
|
next unless /^puppet-/ =~ repo.name
|
|
|
|
unless File.directory? dest = "puppet/#{repo.name}"
|
|
system "git", "clone", repo.clone_url, dest
|
|
end
|
|
end
|