Created
May 9, 2017 10:41
-
-
Save dorsegal/368672c46f555f9b8a78ab0f43733cb5 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
$LOAD_PATH.push File.expand_path("spaceship/lib") | |
require "spaceship" | |
require "date" | |
require 'rubygems' | |
require 'dogapi' | |
# this application requiers fastlane installed and sapceship working. | |
# in addition please install datadig api for ruby | |
# Datadog api keys | |
api_key = API_KEY | |
application_key = APPLICATION_KEY | |
max_days = 30 # maximum day before alerting | |
user = APPLE_ACCOUNT | |
password = APPLE_ACCOUNT_PASSWORD | |
# Create a statsd client instance. | |
dog = Dogapi::Client.new(api_key, application_key) | |
# Log in to apple developer console | |
Spaceship::Portal.login(user, password) | |
# for eatch team write the name of the team the the certificate that will expires in $max_days | |
teams = Spaceship::Portal.client.teams | |
teams.each do |team| | |
puts "#############" | |
print "team: #{team['name']}\n" | |
Spaceship::Portal.client.team_id = team['teamId'] | |
certificates = Spaceship::Portal.certificate.all | |
certificates.each do |elem| | |
name = elem.raw_data["certificate"]['name'] | |
date = Date.parse elem.raw_data["certificate"]['expirationDate'] | |
if date <= Date.today + max_days | |
expiresin = date - Date.today | |
dog.emit_point('apple.certificate.expires_in', expiresin, :tags => ["Name:#{name}"]) | |
print "#{name} expires in #{expiresin} days\n" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment