Created
January 9, 2020 19:00
-
-
Save tangrufus/7a083fba3ea64c71cdab07630933cc49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "http" | |
require 'json' | |
require 'open3' | |
http = HTTP.auth("token XXXXX") | |
max_page=12 | |
clone_urls = (1..max_page).map do |page| | |
body = http.get("https://api.github.com/orgs/itinerisltd/repos?type=sources&sort=created&page=#{page}").body | |
repos = JSON.parse(body) | |
repos.map do |repo| | |
repo.dig("clone_url") | |
end | |
end.flatten | |
clone_urls = clone_urls.select do |url| | |
url.include? "bedrock" | |
end | |
puts "=============" | |
successful_repos = [] | |
clone_urls.each do |url| | |
puts url | |
site = url.split('/').last.chomp(".git") | |
puts "Running #{site}" | |
_, _, status = Open3.capture3("git clone --branch production #{url} bedrocks/#{site}") | |
is_bedrock = File.exist?("bedrocks/#{site}/composer.lock") && File.exist?("bedrocks/#{site}/config/application.php") | |
puts "Skip: bedrocks/#{site} is not bedrock" unless is_bedrock | |
next unless is_bedrock && status.success? | |
Dir.chdir("bedrocks/#{site}") do | |
_, _, status = Open3.capture3("git checkout -b auto-update-iwp-client-2020-01-09") | |
_, _, status = Open3.capture3("composer require wpackagist-plugin/iwp-client") if status.success? | |
_, _, status = Open3.capture3("git add composer.json") if status.success? | |
_, _, status = Open3.capture3("git add composer.lock") if status.success? | |
_, _, status = Open3.capture3("git commit -m 'composer require wpackagist-plugin/iwp-client via auto script'") if status.success? | |
_, _, status = Open3.capture3("git push origin Head") if status.success? | |
_, _, status = Open3.capture3("hub pull-request -b production -m 'composer require wpackagist-plugin/iwp-client via auto script'") if status.success? | |
end | |
end.compact | |
puts "=============" | |
puts "Done: Now go to these repos and cehck the pull requests" | |
puts clone_urls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment