Sha256: d50382a0161905611fe38dd69ddde92632a0fac7d775298d949b0ab8d58c4d7e

Contents?: true

Size: 903 Bytes

Versions: 3

Compression:

Stored size: 903 Bytes

Contents

require 'rake_factory'

module RakeGithub
  module Tasks
    module DeployKey
      class Destroy < RakeFactory::Task
        default_name :destroy
        default_description RakeFactory::DynamicValue.new { |t|
          "Destroys deploy key from the #{t.repository} repository"
        }

        parameter :repository, required: true
        parameter :access_token, required: true
        parameter :title, required: true

        action do |t|
          client = Octokit::Client.new(access_token: access_token)

          print "Removing deploy key '#{t.title}' from the " +
              "'#{t.repository}' repository... "
          deploy_keys = client.list_deploy_keys(t.repository)
          deploy_key = deploy_keys.find { |k| k[:title] == t.title }
          client.remove_deploy_key(t.repository, deploy_key[:id]) if deploy_key
          puts "Done."
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake_github-0.2.0.pre.5 lib/rake_github/tasks/deploy_key/destroy.rb
rake_github-0.2.0.pre.4 lib/rake_github/tasks/deploy_key/destroy.rb
rake_github-0.2.0.pre.3 lib/rake_github/tasks/deploy_key/destroy.rb