You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

invite-collaborator 792 B

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env ruby
  2. require 'octokit'
  3. class Team
  4. attr_reader :gh, :name
  5. def initialize(gh, name)
  6. @gh = gh
  7. @name = name
  8. end
  9. def add_member(login)
  10. gh.add_team_membership(id, login)
  11. end
  12. def id
  13. team['id']
  14. end
  15. def team
  16. @team ||=
  17. gh.organization_teams('cucumber')
  18. .find { |team| team['name'] == name } || raise("Unable to find a team named #{name}")
  19. end
  20. end
  21. begin
  22. token = ENV['GITHUB_TOKEN'] || raise('You need to set GITHUB_TOKEN')
  23. login = (ARGV[0] || raise("syntax: #{$PROGRAM_NAME} <COLLABORATOR_LOGIN>")).to_s
  24. gh = Octokit::Client.new(access_token: token)
  25. [
  26. Team.new(gh, 'cucumber-ruby'),
  27. Team.new(gh, 'collaborators')
  28. ].each do |team|
  29. team.add_member(login)
  30. end
  31. rescue StandardError => e
  32. abort e.message
  33. end

No Description

Contributors (1)