Skip to content

Commit 253f4a2

Browse files
darmielShegox
authored andcommitted
feat: migration assistant - OAuth App <> GitHub Apps (cla-assistant#1024)
Co-authored-by: Tobias Gabriel <tobias.gabriel@sap.com>
1 parent 57d9011 commit 253f4a2

40 files changed

+1251
-179
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
node_modules/
66
Dockerfile
7+
.env

.env.example

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ export PORT=5000
22
export PROTOCOL=http
33
export HOST=localhost
44
export MONGODB=mongodb://cla_assistant:cla_assistant@localhost:27017/cla_assistant
5+
6+
export GITHUB_APP_NAME=
7+
export GITHUB_APP_PRIVATE_KEY=
8+
export GITHUB_APP_ID=
9+
export GITHUB_APP_CLIENT=
10+
export GITHUB_APP_SECRET=
11+
export GITHUB_APP_WEBHOOK_SECRET=
12+
513
export GITHUB_CLIENT=
614
export GITHUB_SECRET=
7-
815
export GITHUB_TOKEN=

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and CLA-assistan
44
SPDX-License-Identifier: Apache-2.0
55
-->
66

7+
## [v3.0.0](https://github.com/cla-assistant/cla-assistant/tree/v3.0.0) (2023-10-16)
8+
9+
:warning: **Breaking Change** This version adds a mandatory migration to GitHub Apps. As an operator you should first create and install the GitHub App on all your organizations and repositories.
10+
11+
**Improvements:**
12+
- feat: migration assistant - OAuth App <> GitHub Apps (#1024)
13+
714
# Change Log
815
## [v2.13.1](https://github.com/cla-assistant/cla-assistant/tree/v2.13.1) (2023-08-15)
916

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ module.exports = function (grunt) {
128128
grunt.registerTask('build', ['uglify', 'sass']);
129129
grunt.registerTask('lint', ['eslint', 'scsslint']);
130130
grunt.registerTask('coverage', ['mocha_istanbul']);
131-
grunt.registerTask('default', ['uglify', 'eslint', 'mochaTest:server', 'karma', 'watch']);
132-
grunt.registerTask('test', ['eslint', 'mochaTest:server', 'karma']);
131+
grunt.registerTask('default', ['uglify', 'eslint', 'mochaTest:server', 'watch']);
132+
grunt.registerTask('test', ['eslint', 'mochaTest:server']);
133133
grunt.registerTask('debug_test', ['mochaTest:debugServer']);
134134
};

README.md

Lines changed: 87 additions & 37 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@octokit/plugin-retry": "^3.0.9",
2525
"@octokit/plugin-throttling": "^3.5.2",
2626
"@octokit/rest": "^18.10.0",
27+
"@octokit/webhooks-methods": "^4.0.0",
2728
"async": "^3.2.1",
2829
"body-parser": "^1.19.0",
2930
"bunyan": "^1.8.15",
@@ -90,7 +91,7 @@
9091
"scripts": {
9192
"build": "node_modules/grunt/bin/grunt build",
9293
"start": "node src/server/src/app.js",
93-
"start:dev": "source .env && node src/server/src/app.js",
94+
"start:dev": "npx grunt build && source .env && node src/server/src/app.js",
9495
"test": "node_modules/grunt/bin/grunt test",
9596
"acceptance_test": "source .env && npx codeceptjs run"
9697
}

src/client/assets/templates/home.html

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ <h5 ng-if="user.value.org_admin" class="col-xs-12 link-topic-2">
3838
<ui-select-match placeholder="select">
3939
<button class="fa fa-times clear-button" ng-click="clear($event, 'repo')"
4040
ng-show="$select.selected.name"></button>
41-
{{$select.selected.full_name || $select.selected.login}}</ui-select-match>
41+
{{$select.selected.full_name || $select.selected.login}}
42+
</ui-select-match>
4243
<ui-select-choices group-by="groupOrgs"
4344
repeat="item in reposAndOrgs | filter: $select.search | notIn:claRepos | notIn:claOrgs">
4445
<span ng-if="item.full_name" class="octicon"
@@ -48,6 +49,9 @@ <h5 ng-if="user.value.org_admin" class="col-xs-12 link-topic-2">
4849
<img src="{{item.avatarUrl}}" alt="" style="width:20px">
4950
</span>
5051
<span ng-if="!item.full_name" ng-bind-html="item.login | highlight: $select.search"></span>
52+
<span ng-if="item.repository_selection">
53+
| ({{item.repository_selection}} repos)
54+
</span>
5155
</ui-select-choices>
5256
</ui-select>
5357
<span ng-if="selected.item && !isRepo(selected.item)">
@@ -56,6 +60,14 @@ <h5 ng-if="user.value.org_admin" class="col-xs-12 link-topic-2">
5660
<input class="form-control" ng-model="selected.item.excludePattern"
5761
placeholder="repo1,repo2,substring1"></input>
5862
</span>
63+
<span ng-id="!selected.item">
64+
<div style="margin-bottom: 5px; margin-top: 5px;">
65+
<i>Can't find your repository?</i>
66+
<a href="https://github.com/apps/{{appName}}/installations/new">
67+
Add the CLA-Assistant app to your repository
68+
</a>
69+
</div>
70+
</span>
5971
</div>
6072
</div>
6173
<h5 class="link-topic-1">
@@ -121,9 +133,26 @@ <h5 class="link-topic-1">
121133

122134
</div>
123135

136+
<div class="well row" style="padding: 2rem; background-color: #0794C6;">
137+
<h3 style="color: white; font-weight: bold;">Missing anything?</h3>
138+
<p style="color: #d2d2d2">
139+
If you can't find your linked repository or organization,
140+
you'll need to add the new CLA-Assistant app to your repository or organization.
141+
</p>
142+
<a class="btn btn-success" href="https://github.com/apps/{{appName}}/installations/new">
143+
Add GitHub App
144+
</a>
145+
</div>
146+
124147
<!-- ----------ACTIVATED ORGS---------- -->
125148
<div ng-if="claOrgs.length > 0" class="row">
126-
<h4 class="col-xs-12" style="margin: 25px 0; padding-left: 0;">Linked Organisations</h4>
149+
<h4 class="col-xs-12" style="margin: 25px 0; padding-left: 0;">
150+
Linked Organisations
151+
<span ng-if="numMigrateOrgs" style="color: red;">
152+
<i class="octicon octicon-alert"></i>
153+
<strong>{{numMigrateOrgs}}</strong> organizations need to be migrated.
154+
</span>
155+
</h4>
127156
</div>
128157
<div ng-if="claOrgs.length > 0" class="well row" style="padding-top:25px;">
129158
<table class="table">
@@ -163,7 +192,13 @@ <h4 class="col-xs-12" style="margin: 25px 0; padding-left: 0;">Linked Organisati
163192

164193
<!-- ----------ACTIVATED REPOS---------- -->
165194
<div class="row">
166-
<h4 class="col-xs-12" style="margin: 25px 0; padding-left: 0;">Linked Repositories</h4>
195+
<h4 class="col-xs-12" style="margin: 25px 0; padding-left: 0;">
196+
Linked Repositories
197+
<span ng-if="numMigrateRepos" style="color: red;">
198+
<i class="octicon octicon-alert"></i>
199+
<strong>{{numMigrateRepos}}</strong> repositories need to be migrated.
200+
</span>
201+
</h4>
167202
</div>
168203
<div class="well row" style="padding-top:25px;">
169204
<table class=" table">
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and CLA-assistant contributors
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
<div class="modal-body modal-primary container" style="text-align: center;">
8+
<div ng-click="cancel()" class="fa fa-times close-button"></div>
9+
10+
<div class="modal-header">
11+
<span class="small-light-text">MIGRATION</span><br>
12+
<span class="big-bold-text">{{item.org}}</span>
13+
<div ng-show="success">
14+
<span class="small-green-text">Migration Successful</span>
15+
</div>
16+
</div>
17+
18+
<div class="row">
19+
<img src="/assets/images/howto4.svg" class="icon-img icon" ng-show="success">
20+
<img src="/assets/images/feature3.svg" class="icon-img icon" ng-show="!success">
21+
</div>
22+
23+
<!-- Default Migrating Notice -->
24+
<div ng-if="checking" class="row">
25+
<h2>Migrating...</h2>
26+
<p>
27+
This process can take a while.
28+
</p>
29+
</div>
30+
31+
<!-- Actual Left Content -->
32+
<div ng-if="!checking" class="row">
33+
<div ng-show="needGitHubApp">
34+
<h2>Install the GitHub App</h2>
35+
<p>
36+
Install the GitHub App to every repository in your organization you plan to use CLA-Assistant on.
37+
The GitHub App will act on your behalf with more restricted permissions.
38+
</p>
39+
<a ng-show="inviteOrganizationID" class="btn btn-success"
40+
href="https://github.com/apps/{{inviteAppName}}/installations/new/permissions?suggested_target_id={{inviteOrganizationID}}">
41+
Install GitHub App
42+
</a>
43+
<br><br>
44+
</div>
45+
<div ng-show="needGitHubAppPrivileges">
46+
<h2>Extend Privileges</h2>
47+
<p>
48+
The GitHub App requires extended permissions.
49+
</p>
50+
<a class="btn btn-info" href="https://github.com/settings/installations/40445958">Update Permissions</a>
51+
<br><br>
52+
</div>
53+
<div ng-show="needCheckMigration">
54+
<h2>Start Migration</h2>
55+
<p>
56+
Click on the button to check if CLA-Assistant can access your repository and start the migration.
57+
</p>
58+
<button class="btn btn-info" ng-show="!checking" ng-click="migrate()">Start Migration</button>
59+
</div>
60+
<div ng-show="errorMsg">
61+
<h2>Error</h2>
62+
<span style="color: red">{{errorMsg}}</span>
63+
</div>
64+
<div ng-show="success">
65+
<h2>Migration Complete!</h2>
66+
<button class="btn btn-info" ng-click="done()">Close Window</button>
67+
</div>
68+
</div>
69+
</div>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and CLA-assistant contributors
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
<div class="modal-body modal-primary container" style="text-align: center;">
8+
<div ng-click="cancel()" class="fa fa-times close-button"></div>
9+
10+
<div class="modal-header">
11+
<span class="small-light-text">MIGRATION</span><br>
12+
<span class="big-bold-text">{{item.owner}}/{{item.repo}}</span>
13+
<div ng-show="success">
14+
<span class="small-green-text">Migration Successful</span>
15+
</div>
16+
</div>
17+
18+
<div class="row">
19+
<img src="/assets/images/howto4.svg" class="icon-img icon" ng-show="success">
20+
<img src="/assets/images/feature3.svg" class="icon-img icon" ng-show="!success">
21+
</div>
22+
23+
<!-- Default Migrating Notice -->
24+
<div ng-if="checking" class="row">
25+
<h2>Migrating...</h2>
26+
<p>
27+
This process can take a while.
28+
</p>
29+
</div>
30+
31+
<!-- Actual Left Content -->
32+
<div ng-if="!checking" class="row">
33+
<div ng-show="needGitHubApp">
34+
<h2>Install the GitHub App</h2>
35+
<p>
36+
Install the GitHub App on each repository where you want to use CLA-Assistant.
37+
The GitHub app will act on your behalf with more restricted permissions.
38+
</p>
39+
<a ng-show="inviteUserID" class="btn btn-success"
40+
href="https://github.com/apps/{{inviteAppName}}/installations/new/permissions?suggested_target_id={{inviteUserID}}&repository_ids[]={{item.repoId}}">
41+
Install GitHub App
42+
</a>
43+
<br><br>
44+
</div>
45+
<div ng-show="needGitHubAppPrivileges">
46+
<h2>Extend Privileges</h2>
47+
<p>
48+
The GitHub App requires extended permissions.
49+
</p>
50+
<a class="btn btn-info" href="https://github.com/settings/installations/40445958">Update Permissions</a>
51+
<br><br>
52+
</div>
53+
<div ng-show="needCheckMigration">
54+
<h2>Start Migration</h2>
55+
<p>
56+
Click on the button to check if CLA-Assistant can access your repository and start the migration.
57+
</p>
58+
<button class="btn btn-info" ng-show="!checking" ng-click="migrate()">Start Migration</button>
59+
</div>
60+
<div ng-show="errorMsg">
61+
<h2>Error</h2>
62+
<span style="color: red">{{errorMsg}}</span>
63+
</div>
64+
<div ng-show="success">
65+
<h2>Migration Complete!</h2>
66+
<button class="btn btn-info" ng-click="done()">Close Window</button>
67+
</div>
68+
</div>
69+
</div>

0 commit comments

Comments
 (0)