codeship_migrate_to_github_app 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +78 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +74 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +6 -0
- data/bin/codeship_migrate_to_github_app +5 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/codeship_migrate_to_github_app.gemspec +34 -0
- data/lib/codeship_migrate_to_github_app.rb +4 -0
- data/lib/codeship_migrate_to_github_app/cli.rb +148 -0
- data/lib/codeship_migrate_to_github_app/version.rb +5 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0e541fdb148de28f3f090e312652d3fe8dcc8e81c127f460b3bdf44b9e9132e9
|
4
|
+
data.tar.gz: b897af7db3a66fad5fa57782a5c29ba3b35a75f44b7a5de93f5cdc688f570494
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0db6dd6c58cd093363a5bc9ea5e2ff0f6f39a790d62682204bcffeb906850887a8cd3d4901af1e83968703630fca666f6c7a2b5321f08217abcf5099bfda8bce
|
7
|
+
data.tar.gz: eb42cda9464c95b779450f54b4da6d923b0ce2396efb23836eeef6c12f2353c2409bd805f6768d6e232f64fbc19c9bcc97346cd2a1dbb445d3ed7effee9815e1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at josh@grorichpuetz.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Project Maintainers
|
69
|
+
|
70
|
+
* Codeship Engineering Team: codeship-engineering@cloudbees.com
|
71
|
+
|
72
|
+
## Attribution
|
73
|
+
|
74
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
75
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
76
|
+
|
77
|
+
[homepage]: http://contributor-covenant.org
|
78
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
codeship_migrate_to_github_app (1.0.0)
|
5
|
+
http (~> 3.3.0)
|
6
|
+
thor (~> 0.20.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.5.2)
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
13
|
+
byebug (10.0.2)
|
14
|
+
coderay (1.1.2)
|
15
|
+
crack (0.4.3)
|
16
|
+
safe_yaml (~> 1.0.0)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
domain_name (0.5.20180417)
|
19
|
+
unf (>= 0.0.5, < 1.0.0)
|
20
|
+
hashdiff (0.3.7)
|
21
|
+
http (3.3.0)
|
22
|
+
addressable (~> 2.3)
|
23
|
+
http-cookie (~> 1.0)
|
24
|
+
http-form_data (~> 2.0)
|
25
|
+
http_parser.rb (~> 0.6.0)
|
26
|
+
http-cookie (1.0.3)
|
27
|
+
domain_name (~> 0.5)
|
28
|
+
http-form_data (2.1.1)
|
29
|
+
http_parser.rb (0.6.0)
|
30
|
+
method_source (0.9.0)
|
31
|
+
pry (0.11.3)
|
32
|
+
coderay (~> 1.1.0)
|
33
|
+
method_source (~> 0.9.0)
|
34
|
+
pry-byebug (3.6.0)
|
35
|
+
byebug (~> 10.0)
|
36
|
+
pry (~> 0.10)
|
37
|
+
public_suffix (3.0.3)
|
38
|
+
rake (10.5.0)
|
39
|
+
rspec (3.8.0)
|
40
|
+
rspec-core (~> 3.8.0)
|
41
|
+
rspec-expectations (~> 3.8.0)
|
42
|
+
rspec-mocks (~> 3.8.0)
|
43
|
+
rspec-core (3.8.0)
|
44
|
+
rspec-support (~> 3.8.0)
|
45
|
+
rspec-expectations (3.8.1)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.8.0)
|
48
|
+
rspec-mocks (3.8.0)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.8.0)
|
51
|
+
rspec-support (3.8.0)
|
52
|
+
safe_yaml (1.0.4)
|
53
|
+
thor (0.20.0)
|
54
|
+
unf (0.1.4)
|
55
|
+
unf_ext
|
56
|
+
unf_ext (0.0.7.5)
|
57
|
+
webmock (3.4.2)
|
58
|
+
addressable (>= 2.3.6)
|
59
|
+
crack (>= 0.3.2)
|
60
|
+
hashdiff
|
61
|
+
|
62
|
+
PLATFORMS
|
63
|
+
ruby
|
64
|
+
|
65
|
+
DEPENDENCIES
|
66
|
+
bundler (~> 1.16)
|
67
|
+
codeship_migrate_to_github_app!
|
68
|
+
pry-byebug (~> 3.6.0)
|
69
|
+
rake (~> 10.0)
|
70
|
+
rspec (~> 3.0)
|
71
|
+
webmock (~> 3.4.2)
|
72
|
+
|
73
|
+
BUNDLED WITH
|
74
|
+
1.16.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 CodeShip
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# CodeshipMigrateToGitHubApp
|
2
|
+
|
3
|
+
This gem helps you migrate large numbers of projects on CodeShip from using legacy GitHub Services to the CodeShip GitHub App. For small numbers of projects, the migration wizard on https://codeship.com can help you migrate. However, there is a limit of 100 projects when migrating using the web UI. We've provided this gem to help users with more than 100 projects to migrate all at once.
|
4
|
+
|
5
|
+
When using the gem, you'll need to provide an access token from GitHub for the gem to have the necessary access. The access token will never leave your local machine though, as everything the gem does is executed in your local environment. If you were to use the web UI, we have enough permissions via your user authentication to perform the migration without needing an access token
|
6
|
+
|
7
|
+
### What's it do?
|
8
|
+
|
9
|
+
First the gem will use the provided user credentials to obtain a list of projects from CodeShip that are using legacy GitHub Services. For each of these projects, the gem will use the provided GitHub personal access token to add the project's GitHub repository to the CodeShip GitHub App. Finally, any legacy Github Service for CodeShip will be removed from the GitHub repository. Errors will be reported for any repository that can't be successfully migrated.
|
10
|
+
|
11
|
+
### Requirements
|
12
|
+
|
13
|
+
To use this gem, you'll need:
|
14
|
+
|
15
|
+
- Ruby >= 2.5.0
|
16
|
+
- CodeShip username and password
|
17
|
+
- GitHub admin access to repositories
|
18
|
+
|
19
|
+
## 1. Install the gem
|
20
|
+
|
21
|
+
gem install codeship_migrate_to_github_app
|
22
|
+
|
23
|
+
## 2. Generate a GitHub Personal Access Token
|
24
|
+
|
25
|
+
Visit [this](https://github.com/settings/tokens) page to generate a personal access token on GitHub. This token needs to be generated by an owner of the organization containing repositories to be migrated. Make sure your token has the following security scopes:
|
26
|
+
|
27
|
+
- repo
|
28
|
+
- admin:org
|
29
|
+
- admin:repo_hook
|
30
|
+
|
31
|
+
![GitHub new personal access token](assets/new_personal_access_token.png)
|
32
|
+
|
33
|
+
Give your token a descriptive name, click 'Generate token', and you'll be taken to a page displaying your new token. Make a note of this token: it won't be displayed on GitHub again.
|
34
|
+
|
35
|
+
![Personal access tokens](assets/personal_access_tokens.png)
|
36
|
+
|
37
|
+
## 3. Install the CodeShip GitHub App for a single repository in your GitHub organization
|
38
|
+
|
39
|
+
For each GitHub organization containing repositories to migrate, you'll need to install the CodeShip GitHub App and add it to at least one repository.
|
40
|
+
|
41
|
+
- Install the CodeShip GitHub App for your organization by visiting <https://github.com/apps/codeship/installations/new>
|
42
|
+
- Select your organization
|
43
|
+
- Under "Repository Access" select "Only select repositories", and choose at least one repository
|
44
|
+
- Click save. You'll be redirected back to CodeShip and can safely close the browser window
|
45
|
+
|
46
|
+
![Repository access](assets/repo_access.png)
|
47
|
+
|
48
|
+
## 4. Run the migration via gem
|
49
|
+
|
50
|
+
codeship_migrate_to_github_app start --codeship-user=<codeship user email> --codeship-pass=<codeship password> --github-token=<github personal access token>
|
51
|
+
|
52
|
+
- codeship-user: your login email address on CodeShip
|
53
|
+
- codeship-pass: your CodeShip account password
|
54
|
+
- github-token: the GitHub personal access token generated in step 2
|
55
|
+
|
56
|
+
## Getting help
|
57
|
+
|
58
|
+
Something not quite right? Reach out to us at <https://helpdesk.codeship.com>
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/codeship/codeship_migrate_to_github_app. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
67
|
+
|
68
|
+
## Code of Conduct
|
69
|
+
|
70
|
+
Everyone interacting in the CodeshipMigrateToGitHubApp project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/codeship/codeship_migrate_to_github_app/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "codeship_migrate_to_github_app"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "codeship_migrate_to_github_app/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "codeship_migrate_to_github_app"
|
8
|
+
spec.version = CodeshipMigrateToGithubApp::VERSION
|
9
|
+
spec.authors = ["Codeship Engineering"]
|
10
|
+
spec.email = ["codeship-engineering@cloudbees.com"]
|
11
|
+
|
12
|
+
spec.summary = "Migrate your Codeship Projects from legacy Github services to Codeship's Github App"
|
13
|
+
spec.description = "Migrate your Codeship Projects from legacy Github services to Codeship's Github App"
|
14
|
+
spec.homepage = "https://github.com/codeship/codeship_migrate_to_github_app"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|assets)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "bin"
|
23
|
+
spec.executables = "codeship_migrate_to_github_app"
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency "webmock", "~> 3.4.2"
|
30
|
+
spec.add_development_dependency "pry-byebug", "~> 3.6.0"
|
31
|
+
|
32
|
+
spec.add_dependency "thor", "~> 0.20.0"
|
33
|
+
spec.add_dependency "http", "~> 3.3.0"
|
34
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "http"
|
5
|
+
|
6
|
+
module CodeshipMigrateToGithubApp
|
7
|
+
class CLI < Thor
|
8
|
+
|
9
|
+
CODESHIP_JSON_HEADER = "application/json"
|
10
|
+
GITHUB_JSON_HEADER = "application/vnd.github.v3+json"
|
11
|
+
GITHUB_INSTALLATIONS_PREVIEW_HEADER = "application/vnd.github.v3+json, application/vnd.github.machine-man-preview+json"
|
12
|
+
|
13
|
+
CODESHIP_AUTH_URL = "https://api.codeship.com/v2/auth"
|
14
|
+
GITHUB_ORGS_URL = "https://api.github.com/user/orgs"
|
15
|
+
CODESHIP_MIGRATION_INFO_URL = "https://api.codeship.com/v2/internal/github_app_migration"
|
16
|
+
GITHUB_INSTALL_URL = "https://api.github.com/user/installations/{installation_id}/repositories/{repository_id}"
|
17
|
+
GITHUB_LIST_HOOKS_URL = "https://api.github.com/repos/{owner}/{repo}/hooks"
|
18
|
+
GITHUB_DELETE_HOOK_URL = "https://api.github.com/repos/{owner}/{repo}/hooks/{hook_id}"
|
19
|
+
|
20
|
+
attr_accessor :codeship_token, :github_org, :codeship_migration_info, :errors
|
21
|
+
|
22
|
+
def self.exit_on_failure?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "start", "Convert projects to use Github app"
|
27
|
+
long_desc <<-LONGDESC
|
28
|
+
`codeship_migrate_to_github_app run` will convert your CodeShip projects
|
29
|
+
utilizing the legacy Github Services to use the CodeShip Github App.
|
30
|
+
LONGDESC
|
31
|
+
option :codeship_user, banner: 'CodeShip user name', type: :string, required: :true
|
32
|
+
option :codeship_pass, banner: 'CodeShip password', type: :string, required: :true
|
33
|
+
option :github_token, banner: 'Github personal access token', type: :string, required: :true
|
34
|
+
def start
|
35
|
+
setup
|
36
|
+
validate_github_credentials(options[:github_token])
|
37
|
+
fetch_codeship_token(options[:codeship_user], options[:codeship_pass])
|
38
|
+
fetch_migration_info
|
39
|
+
migrate
|
40
|
+
report
|
41
|
+
end
|
42
|
+
|
43
|
+
no_commands do
|
44
|
+
def setup
|
45
|
+
@errors = Array.new
|
46
|
+
end
|
47
|
+
|
48
|
+
def fetch_codeship_token(user, pass)
|
49
|
+
response = HTTP.headers(accept: CODESHIP_JSON_HEADER).basic_auth(user: user, pass: pass).post(CODESHIP_AUTH_URL)
|
50
|
+
unless response.code == 200
|
51
|
+
raise Thor::Error.new "Error authenticating to CodeShip: #{response.code}: #{response.to_s}"
|
52
|
+
end
|
53
|
+
@codeship_token = response.parse["access_token"]
|
54
|
+
end
|
55
|
+
|
56
|
+
def validate_github_credentials(token)
|
57
|
+
response = HTTP.headers(accept: GITHUB_JSON_HEADER).auth("token #{token}").get(GITHUB_ORGS_URL)
|
58
|
+
unless response.code == 200
|
59
|
+
raise Thor::Error.new "Error authenticating to Github: #{response.code}: #{response.to_s}"
|
60
|
+
end
|
61
|
+
@github_token = token
|
62
|
+
end
|
63
|
+
|
64
|
+
def fetch_migration_info
|
65
|
+
response = HTTP.headers(accept: CODESHIP_JSON_HEADER).auth("token #{@codeship_token}").get(CODESHIP_MIGRATION_INFO_URL)
|
66
|
+
unless response.code == 200
|
67
|
+
raise Thor::Error.new "Error retrieving migration info from CodeShip: #{response.code}: #{response.to_s}"
|
68
|
+
end
|
69
|
+
|
70
|
+
@codeship_migration_info = response.parse&.fetch("installations")&.fetch("installations")
|
71
|
+
end
|
72
|
+
|
73
|
+
def migrate
|
74
|
+
@codeship_migration_info.each do |installation|
|
75
|
+
installation["repositories"].each do |repo|
|
76
|
+
response = HTTP.headers(accept: GITHUB_INSTALLATIONS_PREVIEW_HEADER)
|
77
|
+
.auth("token #{@github_token}")
|
78
|
+
.put(github_install_url(installation["installation_id"], repo["repository_id"]))
|
79
|
+
unless response.code == 204
|
80
|
+
@errors << repo["repository_name"]
|
81
|
+
end
|
82
|
+
remove_legacy_service(repo["repository_name"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def github_install_url(installation_id, repo_id)
|
88
|
+
GITHUB_INSTALL_URL.sub('{installation_id}', installation_id.to_s).sub('{repository_id}', repo_id.to_s)
|
89
|
+
end
|
90
|
+
|
91
|
+
def remove_legacy_service(repo_name)
|
92
|
+
owner, repo = parse_repo_name(repo_name)
|
93
|
+
|
94
|
+
hook_id = find_legacy_codeship_hook(owner, repo)
|
95
|
+
if hook_id
|
96
|
+
delete_hook(owner, repo, hook_id)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def find_legacy_codeship_hook(owner, repo)
|
101
|
+
response = HTTP.headers(accept: GITHUB_JSON_HEADER)
|
102
|
+
.auth("token #{@github_token}")
|
103
|
+
.get(github_list_hooks_url(owner, repo))
|
104
|
+
if response.code == 200
|
105
|
+
hook = response.parse.find do |hook|
|
106
|
+
hook["name"] == 'codeship'
|
107
|
+
end
|
108
|
+
end
|
109
|
+
hook&.fetch("id")
|
110
|
+
end
|
111
|
+
|
112
|
+
def delete_hook(owner, repo, hook_id)
|
113
|
+
response = HTTP.headers(accept: GITHUB_JSON_HEADER)
|
114
|
+
.auth("token #{@github_token}")
|
115
|
+
.delete(github_delete_hook_url(owner, repo, hook_id))
|
116
|
+
end
|
117
|
+
|
118
|
+
def parse_repo_name(repo_name)
|
119
|
+
repo_name.split('/')
|
120
|
+
end
|
121
|
+
|
122
|
+
def github_list_hooks_url(owner, repo)
|
123
|
+
GITHUB_LIST_HOOKS_URL.sub('{owner}', owner).sub('{repo}', repo)
|
124
|
+
end
|
125
|
+
|
126
|
+
def github_delete_hook_url(owner, repo, hook_id)
|
127
|
+
GITHUB_DELETE_HOOK_URL.sub('{owner}', owner).sub('{repo}', repo).sub('{hook_id}', hook_id.to_s)
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
def report
|
132
|
+
unless @errors.empty?
|
133
|
+
puts "Couldn't install the CodeShip Github app for some repositories, please make the Github token you are \
|
134
|
+
using has admin rights to your Github organization. For help, contact supoprt at https://helpdesk.codeship.com"
|
135
|
+
puts "Error migrating the following repos:"
|
136
|
+
@errors.each do |repo_name|
|
137
|
+
puts "\t#{repo_name}"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
if @codeship_migration_info.empty?
|
141
|
+
puts "No migration required"
|
142
|
+
else
|
143
|
+
puts "Migration complete!"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codeship_migrate_to_github_app
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Codeship Engineering
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.4.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.4.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.6.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.6.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.20.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.20.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: http
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.3.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.3.0
|
111
|
+
description: Migrate your Codeship Projects from legacy Github services to Codeship's
|
112
|
+
Github App
|
113
|
+
email:
|
114
|
+
- codeship-engineering@cloudbees.com
|
115
|
+
executables:
|
116
|
+
- codeship_migrate_to_github_app
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".ruby-version"
|
123
|
+
- CODE_OF_CONDUCT.md
|
124
|
+
- Gemfile
|
125
|
+
- Gemfile.lock
|
126
|
+
- LICENSE.txt
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- bin/codeship_migrate_to_github_app
|
130
|
+
- bin/console
|
131
|
+
- bin/setup
|
132
|
+
- codeship_migrate_to_github_app.gemspec
|
133
|
+
- lib/codeship_migrate_to_github_app.rb
|
134
|
+
- lib/codeship_migrate_to_github_app/cli.rb
|
135
|
+
- lib/codeship_migrate_to_github_app/version.rb
|
136
|
+
homepage: https://github.com/codeship/codeship_migrate_to_github_app
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.7.3
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: Migrate your Codeship Projects from legacy Github services to Codeship's
|
160
|
+
Github App
|
161
|
+
test_files: []
|