@bigbinary/neeto-github-frontend 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,296 @@
1
+ # neeto-github-nano
2
+
3
+ A Ruby gem that manages GitHub integration across neeto products
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem "neeto-github-engine", git: "https://#{github_auth_string}@github.com/bigbinary/neeto-github-nano.git", branch: "stable"
11
+
12
+ gem "octokit"
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```bash
18
+ bundle
19
+ ```
20
+
21
+ Or use `gem install`:
22
+
23
+ ```bash
24
+ gem install neeto-github-engine octokit
25
+ ```
26
+
27
+ ## Migration
28
+
29
+ To Copy migration files, run:
30
+
31
+ ```bash
32
+ rails g neeto_github_engine:install
33
+ ```
34
+
35
+ After adding the migration file, run:
36
+
37
+ ```bash
38
+ bundle exec rails db:migrate
39
+ ```
40
+
41
+ ## Integration
42
+
43
+ `neeto-github-engine` supports OAuth apps and GitHub apps. Depending upon the use case you can use either one or both together. Refer to the link below to understand the differences between a Github app and an OAuth app: <https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/differences-between-github-apps-and-oauth-apps>
44
+
45
+ 1. [Integrate OAuth app](#integrate-oauth-app)
46
+ 2. [Integrate GitHub app](#integrate-github-app)
47
+
48
+ ## Integrate OAuth app
49
+
50
+ ### Create an OAuth app on GitHub
51
+
52
+ Refer to this: <https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app>
53
+
54
+ Set the Callback URL as:
55
+
56
+ ```text
57
+ https://connect.neeto<AppName>.com
58
+ ```
59
+
60
+ Here, the subdomain can be anything like `connect` or `app`.
61
+ The domain will be the application domain.
62
+ Create different OAuth apps for staging and production.
63
+
64
+ After getting the `client_id` and `client_secret`,
65
+ add this to the `secrets.yml` file in your application.
66
+
67
+ ```yml
68
+ default:
69
+ github_oauth_app:
70
+ client_id: <%= ENV["GITHUB_CLIENT_ID"] %>
71
+ client_secret: <%= ENV["GITHUB_CLIENT_SECRET"] %>
72
+ ```
73
+
74
+ and add the secrets to ENV.
75
+
76
+ ### Add JWT private and public keys
77
+
78
+ Run the following ruby command to generate an RSA key pair:
79
+
80
+ ```ruby
81
+ rsa = OpenSSL::PKey::RSA.generate(2048)
82
+ ```
83
+
84
+ The following command prints the private key:
85
+
86
+ ```ruby
87
+ rsa.to_s
88
+ ```
89
+
90
+ The following command prints the public key:
91
+
92
+ ```ruby
93
+ rsa.public_key.to_s
94
+ ```
95
+
96
+ Store the private and public keys as environment variables,
97
+ let's say, as `JWT_PRIVATE_KEY` and `JWT_PUBLIC_KEY`, respectively.
98
+ Then add the keys to the `secrets.yml` file in your application,
99
+ as shown below:
100
+
101
+ ```yml
102
+ default:
103
+ jwt:
104
+ private_key: <%= ENV['JWT_PRIVATE_KEY'].inspect %>
105
+ public_key: <%= ENV['JWT_PUBLIC_KEY'].inspect %>
106
+ ```
107
+
108
+ ### Add association
109
+
110
+ ```bash
111
+ rails g neeto_github_engine:integration <entity>
112
+ ```
113
+
114
+ For example, if the `organization` model should have many accounts, you should run:
115
+
116
+ ```bash
117
+ rails g neeto_github_engine:integration organization
118
+ ```
119
+
120
+ This will add `NeetoGithubEngine::Integratable` concern to the `Organization` model.
121
+
122
+ ### Controllers to store the access token
123
+
124
+ - `AuthorizeController` (`/neeto_github/authorize`)
125
+ This action accepts 4 params:
126
+
127
+ 1. integrator_type
128
+ 2. integrator_id
129
+ 3. redirect_path
130
+ 4. scope
131
+
132
+ For Example, if the `Organization` is the integrator of accounts then redirect the user to:
133
+
134
+ ```js
135
+ /neeto_github/authorize?${qs.stringify({
136
+ integrator_type: 'Organization',
137
+ integrator_id: organizationId,
138
+ scope: "repo",
139
+ redirect_path: `/settings/github-integration`,
140
+ })}
141
+ ```
142
+
143
+ where the `scope` is what scope level application needs to access GitHub and
144
+ `redirect_path` is where the user needs to be redirected after the authorization is completed.
145
+
146
+ ### Controllers
147
+
148
+ ```ruby
149
+ NeetoGithubEngine::AccountsController
150
+ ```
151
+
152
+ The controller mentioned above can be used to fetch GitHub accounts.
153
+
154
+ Mandatory params:
155
+
156
+ - `integrator_id`
157
+ - `integrator_type`
158
+
159
+ ### Add Repository to Entity
160
+
161
+ ```bash
162
+ rails g neeto_github_engine:repository <entity>
163
+ ```
164
+
165
+ The above command will:
166
+
167
+ 1. Create a file in `app/models` with the name `<entity>Repository.rb`.
168
+ 2. Add an association to the entity model.
169
+
170
+ ### Link Pull Request With Entity
171
+ ```
172
+ include NeetoGithubEngine::Linkable
173
+ ```
174
+ The above concern will associate the entity with `NeetoGithubEngine::PullRequest` Model.
175
+
176
+ ### Using controllers
177
+
178
+ - Controllers must inherit from
179
+
180
+ ```ruby
181
+ NeetoGithubEngine::BaseController
182
+ ```
183
+
184
+ Mandatory params: account_id
185
+
186
+ ## Integrate GitHub app
187
+
188
+ ### Create a GitHub app in GitHub
189
+
190
+ Refer: https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app
191
+
192
+ **⚠️ When creating a GitHub app make sure to not to include spaces or special characters (except hyphen ``-``) in the GitHub App name field**
193
+
194
+ Set the post installation setup url in the GitHub app's general settings page as:
195
+ ```
196
+ https://app.neeto<AppName>.com/neeto_github/app_installations/callbacks
197
+ ```
198
+ Here, the subdomain can be anything like connect or app. The domain will be the application domain.
199
+
200
+ Enable the webhooks and set the webhook url as:
201
+
202
+ ```
203
+ https://app.neeto<AppName>.com/neeto_github/webhooks
204
+ ```
205
+ You can choose a random string of text with high entropy as `webhook_secret`.
206
+
207
+ After getting the `app_id`, `app_name`, `private_key` and `webhook_secret`, add them to the secrets.yml file in your application.
208
+
209
+ ```yml
210
+ default: &default
211
+ github_app:
212
+ id: <%= ENV["GITHUB_APP_ID"] %>
213
+ name: <%= ENV["GITHUB_APP_NAME"] %>
214
+ private_key: <%= ENV["GITHUB_APP_PRIVATE_KEY"].inspect %>
215
+ webhook_secret: <%= ENV["GITHUB_APP_WEBHOOK_SECRET"] %>
216
+ ```
217
+
218
+ Follow the steps of OAuth app integration for adding [JWT private and public keys](#add-jwt-private-and-public-keys) and [association](#add-association).
219
+
220
+
221
+ ### Install GitHub app
222
+
223
+ `AppInstallationsController#new` Used to install the github app in the user specified repositories. This action accepts 4 URL query parameters:
224
+
225
+ 1. integrator_type
226
+ 2. integrator_id
227
+ 3. redirect_path
228
+ 4. fallback_redirect_path
229
+
230
+ Here the `redirect_path` is where the user needs to be redirected after the installation is completed and `fallback_redirect_path` is where the user needs to redirected in case of any error.
231
+
232
+ ```
233
+ GET /neeto_github/app_installations/new?integrator_type=<integrator_type>&integrator_id=<integrator_id>&redirect_path=/settings&fallback_redirect_path=/settings
234
+ ```
235
+
236
+ ### Fetch app installations
237
+
238
+ `AppInstallationsController#index` Used to list app installations that are associated with an integrator. This action accepts 4 URL query parameters:
239
+
240
+ 1. integrator_type
241
+ 2. integrator_id
242
+ 3. page_size (optional)
243
+ 4. page (optional)
244
+
245
+ ```
246
+ GET /neeto_github/app_installations?integrator_type=<integrator_type>&integrator_id=<integrator_id>&page_size=10&page=1
247
+ ```
248
+
249
+ ### Destroy app installation
250
+
251
+ `AppInstallationsController#destroy` Used to destroy a particular `AppInstallation`. This action accepts 3 URL parameters:
252
+
253
+ Query parameters:
254
+ 1. integrator_type
255
+ 2. integrator_id
256
+
257
+ Path parameters:
258
+ 1. app_installation_id
259
+
260
+ ```
261
+ DELETE /neeto_github/app_installations/<app_installation_id>?integrator_type=<integrator_type>&integrator_id=<integrator_id>
262
+ ```
263
+
264
+ ### Fetch app installation repositories
265
+
266
+ `AppInstallations::RepositoriesController#index` Used to list the repositories of an installed github app. This action accepts 3 URL parameters:
267
+
268
+ Query parameters:
269
+ 1. integrator_type
270
+ 2. integrator_id
271
+
272
+ Path parameters:
273
+ 1. app_installation_id
274
+
275
+ ```
276
+ GET /neeto_github/app_installations/<app_installation_id>/repositories?integrator_id=<integrator_id>&integrator_type=<integrator_type>
277
+ ```
278
+
279
+ ### Get an issue detail
280
+
281
+ `AppInstallations::Repositories::IssuesController#Issue` This action provides the details of an github issue. This action accepts 5 URL parameters:
282
+
283
+ Query parameters:
284
+ 1. integrator_type
285
+ 2. integrator_id
286
+
287
+ Path parameters:
288
+ 1. app_installation_id
289
+ 4. repository_full_name
290
+ 3. issue_number
291
+
292
+ `repository_full_name` should be URL encoded. You can use `encodeURIComponent` javascript method to URL encode `repository_full_name`.
293
+
294
+ ```
295
+ GET /neeto_github/app_installations/<app_installation_id>/repositories/<url_encoded_repository_full_name>/issues/<issue_number>?integrator_id=<integrator_id>&integrator_type=<integrator_type>
296
+ ```
@@ -0,0 +1,25 @@
1
+ {
2
+ "connect": "Connect",
3
+ "github": "Github",
4
+ "noRepos": "No repositories found",
5
+ "noReposDescription": "Connect a GitHub repository to begin using your existing repos for new services.",
6
+ "notConnectedDescription": "Connect your neetoCI account to GitHub to begin using your existing repos for new services.",
7
+ "configureAccount": "Configure account",
8
+ "connectAccount": "Connect account",
9
+ "connectGithub": "Connect GitHub",
10
+ "connectARepo": "Connect a repository",
11
+ "connectRepository": "Connect repository",
12
+ "continue": "Continue",
13
+ "publicGitRepo": "Public Git repository",
14
+ "publicGitRepoDescription": "Use a public repository by entering the URL below.",
15
+ "publicGitRepoPlaceholder": "https://github.com/bigbinary/example-app",
16
+ "countOf": {
17
+ "repos_one": "{{count}} repo",
18
+ "repos_other": "{{count}} repos"
19
+ },
20
+ "neetoGithubNanoModal": {
21
+ "title": "Create a new project",
22
+ "description": "Connect your Git repository or use an existing public repository URL."
23
+ },
24
+ "troubleshoot": "Can't find a repository that's already connected? <troubleshootLink>Troubleshoot</troubleshootLink> your GitHub connection."
25
+ }