Sha256: 28cd4d96520330953b6005d83a7b4bd2c00cb3e099a07d1ba5664116827b8cea

Contents?: true

Size: 1.12 KB

Versions: 15

Compression:

Stored size: 1.12 KB

Contents

require 'rake_factory'
require 'octokit'

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

        parameter :repository, required: true
        parameter :access_token, required: true
        parameter :deploy_keys, default: []

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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rake_github-0.10.0.pre.3 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.10.0.pre.2 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.10.0.pre.1 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.9.0 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.12 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.11 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.10 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.9 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.8 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.7 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.6 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.5 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.4 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.3 lib/rake_github/tasks/deploy_keys/destroy.rb
rake_github-0.8.0.pre.2 lib/rake_github/tasks/deploy_keys/destroy.rb