travis_migrate_to_apps 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +74 -0
- data/lib/travis_migrate_to_apps/cli.rb +17 -9
- data/lib/travis_migrate_to_apps/version.rb +1 -1
- metadata +4 -5
- data/Gemfile.lock +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 11aa9acdabfe9c4b3266ef1c1561efab04abd4ac06f89cb02931ebe29580cbb3
|
4
|
+
data.tar.gz: 21d585480351fbd6bc1e3745025e6aba13208d23a64e4f4bc32ca08f0499dfd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ddb124d2978f0845f223287e6e7bf4a688179793371971a05aa134b918889ae8dddd41ee805b050236431705fdb71c283b24851646c3f05839692f7a1d2271b
|
7
|
+
data.tar.gz: 550a753c4c3f6c654923ca8fc5b0c994707b3dd4e884cfdfb141427fd387f4aa29aaf63047a9bc160e079ff82c7291cf52a4c211924df259ea06fab99da4a524
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Migrate your GitHub organizations to use the Travis CI GitHub App integration
|
2
|
+
|
3
|
+
This gem will help you migrate the repositories you have on [https://travis-ci.com](travis-ci.com) from legacy [GitHub Services](https://developer.github.com/v3/guides/replacing-github-services/) integration to the new [GitHub Apps](https://developer.github.com/apps/) integration.
|
4
|
+
|
5
|
+
The main difference is that you will now give Travis CI access to your repositories on a repository basis instead of giving it access to all of them.
|
6
|
+
|
7
|
+
Hence, we have developped this gem to help you migrate your repositories that are currently active on Travis CI in one sweep rather than having to add them manually one by one in the GitHub UI.
|
8
|
+
|
9
|
+
Here are the steps:
|
10
|
+
|
11
|
+
## 1. Install the gem
|
12
|
+
```
|
13
|
+
gem install travis_migrate_to_apps
|
14
|
+
```
|
15
|
+
|
16
|
+
## 2. Generate a GitHub personal access token with repo scope
|
17
|
+
|
18
|
+
You can generate a new GitHub token [here](https://github.com/settings/tokens/new).
|
19
|
+
|
20
|
+
Choose the name of your liking and ensure to select the whole `repo` scope as shown below:
|
21
|
+
|
22
|
+
![GitHub new token page](https://github.com/travis-ci/travis_migrate_to_apps/blob/assets/github-token-new.png)
|
23
|
+
|
24
|
+
Then click the "Generate token" button at the bottom to generate the token.
|
25
|
+
|
26
|
+
You'll then be back on the GitHub token page:
|
27
|
+
|
28
|
+
![GitHub token page](https://github.com/travis-ci/travis_migrate_to_apps/blob/assets/github-token-added.png)
|
29
|
+
|
30
|
+
Take care of copying the newly generated token and save it for later usage.
|
31
|
+
|
32
|
+
**Note: if you are migrating an organization, the token must be generated by [an owner of the GitHub organization](https://help.github.com/articles/permission-levels-for-an-organization/).**
|
33
|
+
|
34
|
+
## 3. Activate the Travis CI GitHub Apps integration with 1 repo
|
35
|
+
|
36
|
+
Go to your profile page on Travis CI: https://travis-ci.com/profile
|
37
|
+
|
38
|
+
Click the "Activate GitHub Apps Integration" button highlighted below:
|
39
|
+
|
40
|
+
![Activate GitHub Apps Integration button](https://github.com/travis-ci/travis_migrate_to_apps/blob/assets/github-apps-button-on-profile-page.png)
|
41
|
+
|
42
|
+
You'll directed to the GitHub Apps page for the Travis CI app:
|
43
|
+
|
44
|
+
![GitHub Apps page](https://github.com/travis-ci/travis_migrate_to_apps/blob/assets/travis-ci-github-app.png)
|
45
|
+
|
46
|
+
Choose at least one repository and click the "Approve & Install" button.
|
47
|
+
|
48
|
+
You'll then be redirected to your profile page on Travis CI and the newly added repository should appear under "GitHub Apps Integration":
|
49
|
+
|
50
|
+
![Travis CI profile page](https://github.com/travis-ci/travis_migrate_to_apps/blob/assets/travis-ci-profile-with-github-apps-integration.png)
|
51
|
+
|
52
|
+
## 4. Get your Travis CI API token
|
53
|
+
|
54
|
+
Here are the two ways you can get this token:
|
55
|
+
|
56
|
+
1. On your profile page: https://travis-ci.com/profile
|
57
|
+
|
58
|
+
![Travis CI token on profile page](https://github.com/travis-ci/travis_migrate_to_apps/blob/assets/travis-ci-token-profile-page.png)
|
59
|
+
|
60
|
+
2. Via the [Travis CI client](https://github.com/travis-ci/travis.rb) by running: `travis token --pro`
|
61
|
+
|
62
|
+
## 5. Run the gem
|
63
|
+
|
64
|
+
```
|
65
|
+
travis_migrate_to_apps [owner_name] [travis_access_token] [github_access_token]
|
66
|
+
```
|
67
|
+
|
68
|
+
where
|
69
|
+
|
70
|
+
- `[owner_name]` is the GitHub account (user or organization) where the repositories you want to migrate are located
|
71
|
+
- `[travis_access_token]` is the Travis CI token obtained in step #4 above
|
72
|
+
- `[github_access_token]` is the GitHub token obtained in step #2 above
|
73
|
+
|
74
|
+
Happy migration!
|
@@ -3,10 +3,10 @@ require 'json'
|
|
3
3
|
require 'colors'
|
4
4
|
|
5
5
|
module TravisMigrateToApps
|
6
|
-
class Cli < Struct.new(:owner_name, :travis_access_token, :github_access_token)
|
6
|
+
class Cli < Struct.new(:owner_name, :travis_access_token, :github_access_token, :api_endpoint, :github_api_endpoint)
|
7
7
|
include Colors
|
8
8
|
|
9
|
-
USAGE = 'Usage: travis_migrate_to_apps [owner_name] [travis_access_token] [github_access_token]'
|
9
|
+
USAGE = 'Usage: travis_migrate_to_apps [owner_name] [travis_access_token] [github_access_token] [travis api endpoint | https://api.travis-ci.com] [github api endpoint | https://api.github.com]'
|
10
10
|
|
11
11
|
MSGS = {
|
12
12
|
start: 'Starting to migrate the account %s to use the Travis CI GitHub App integration.',
|
@@ -23,11 +23,11 @@ module TravisMigrateToApps
|
|
23
23
|
|
24
24
|
URIS = {
|
25
25
|
travis: {
|
26
|
-
installation: '
|
27
|
-
repositories: '
|
26
|
+
installation: '%s/owner/%s?include=owner.installation',
|
27
|
+
repositories: '%s/owner/%s/repos?repository.active=true&repository.managed_by_installation=false&limit=%i&offset=%i'
|
28
28
|
},
|
29
29
|
github: {
|
30
|
-
installation_repos: '
|
30
|
+
installation_repos: '%s/user/installations/%i/repositories/%i'
|
31
31
|
}
|
32
32
|
}
|
33
33
|
|
@@ -46,11 +46,19 @@ module TravisMigrateToApps
|
|
46
46
|
PER_PAGE = 20
|
47
47
|
|
48
48
|
attr_reader :installation
|
49
|
+
attr_reader :api_endpoint
|
50
|
+
attr_reader :github_api_endpoint
|
49
51
|
|
50
52
|
def initialize(*)
|
51
53
|
super
|
52
54
|
to_h.keys.each do |key|
|
53
|
-
|
55
|
+
if key == :api_endpoint
|
56
|
+
@api_endpoint = to_h[key] ? to_h[key] : 'https://api.travis-ci.com'
|
57
|
+
elsif key == :github_api_endpoint
|
58
|
+
@github_api_endpoint = to_h[key] ? to_h[key] : 'https://api.github.com'
|
59
|
+
else
|
60
|
+
missing_arg(key) unless send(key)
|
61
|
+
end
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
@@ -86,21 +94,21 @@ module TravisMigrateToApps
|
|
86
94
|
|
87
95
|
def migrate_repo(repo)
|
88
96
|
msg :migrating_repo, repo['name'], nl: false
|
89
|
-
uri = uri(:github, :installation_repos, installation['github_id'], repo['github_id'])
|
97
|
+
uri = uri(:github, :installation_repos, github_api_endpoint, installation['github_id'], repo['github_id'])
|
90
98
|
request(:put, uri, headers(:github))
|
91
99
|
msg :migrated_repo, repo['name']
|
92
100
|
end
|
93
101
|
|
94
102
|
def fetch_installation
|
95
103
|
msg :fetch_installation, owner_name
|
96
|
-
uri = uri(:travis, :installation, owner_name)
|
104
|
+
uri = uri(:travis, :installation, api_endpoint, owner_name)
|
97
105
|
data = request(:get, uri, headers(:travis))
|
98
106
|
data['installation']
|
99
107
|
end
|
100
108
|
|
101
109
|
def fetch_repos(repos = [], page = 1)
|
102
110
|
offset = (page - 1) * PER_PAGE
|
103
|
-
uri = uri(:travis, :repositories, owner_name, PER_PAGE, offset)
|
111
|
+
uri = uri(:travis, :repositories, api_endpoint, owner_name, PER_PAGE, offset)
|
104
112
|
data = request(:get, uri, headers(:travis))
|
105
113
|
repos += data['repositories'].map { |repo| only(repo, 'name', 'github_id') }
|
106
114
|
repos = fetch_repos(repos, page + 1) unless data['@pagination']['is_last']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis_migrate_to_apps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis CI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Migrate your GitHub organizations to use the Travis CI GitHub App integration.
|
14
14
|
email:
|
@@ -19,8 +19,8 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- Gemfile
|
22
|
-
- Gemfile.lock
|
23
22
|
- LICENSE.md
|
23
|
+
- README.md
|
24
24
|
- bin/travis_migrate_to_apps
|
25
25
|
- lib/colors.rb
|
26
26
|
- lib/travis_migrate_to_apps.rb
|
@@ -45,8 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
|
-
|
49
|
-
rubygems_version: 2.6.13
|
48
|
+
rubygems_version: 3.1.2
|
50
49
|
signing_key:
|
51
50
|
specification_version: 4
|
52
51
|
summary: Migrate your GitHub organizations to use the Travis CI GitHub App integration
|
data/Gemfile.lock
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
travis_migrate_to_apps (0.0.3)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
addressable (2.5.2)
|
10
|
-
public_suffix (>= 2.0.2, < 4.0)
|
11
|
-
crack (0.4.3)
|
12
|
-
safe_yaml (~> 1.0.0)
|
13
|
-
diff-lcs (1.3)
|
14
|
-
hashdiff (0.3.7)
|
15
|
-
public_suffix (3.0.2)
|
16
|
-
rspec (3.7.0)
|
17
|
-
rspec-core (~> 3.7.0)
|
18
|
-
rspec-expectations (~> 3.7.0)
|
19
|
-
rspec-mocks (~> 3.7.0)
|
20
|
-
rspec-core (3.7.1)
|
21
|
-
rspec-support (~> 3.7.0)
|
22
|
-
rspec-expectations (3.7.0)
|
23
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.7.0)
|
25
|
-
rspec-mocks (3.7.0)
|
26
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.7.0)
|
28
|
-
rspec-support (3.7.1)
|
29
|
-
safe_yaml (1.0.4)
|
30
|
-
webmock (3.3.0)
|
31
|
-
addressable (>= 2.3.6)
|
32
|
-
crack (>= 0.3.2)
|
33
|
-
hashdiff
|
34
|
-
|
35
|
-
PLATFORMS
|
36
|
-
ruby
|
37
|
-
|
38
|
-
DEPENDENCIES
|
39
|
-
rspec
|
40
|
-
travis_migrate_to_apps!
|
41
|
-
webmock
|
42
|
-
|
43
|
-
BUNDLED WITH
|
44
|
-
1.16.1
|