Skip to content

Instantly share code, notes, and snippets.

@momolog
Created May 29, 2019 13:28
Show Gist options
  • Save momolog/fa6ed94b77e98e38eea474699a71683a to your computer and use it in GitHub Desktop.
Save momolog/fa6ed94b77e98e38eea474699a71683a to your computer and use it in GitHub Desktop.
githost export status
#!/usr/bin/env ruby
require 'json'
require 'httparty'
headers = {
'PRIVATE-TOKEN' => ENV['GITHOST_PERSONAL_API_TOKEN']
}
(1..121).each do |pid|
url = "https://giantmonkey.githost.io/api/v4/projects/#{pid}/export"
response = HTTParty.get url, headers: headers
if response.success?
result = JSON.parse(response.body)
p "#{result['id']}: #{result['name']} #{result['export_status']}"
# unless ['finished', 'started'].include? result['export_status']
# p "-> triggering export for project #{result['id']} #{result['name']}"
# trigger_response = HTTParty.post url, headers: headers
# trigger_result = JSON.parse(trigger_response.body)
# p trigger_result
# end
else
p "#{pid}: no such project."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment