Skip to content

Commit e7864b7

Browse files
codeongithub-actions[bot]Atul-Butola
authored
fix link (#146)
* fix link * minor grammar fixes * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update perform-external-action.mdx * Update fern/docs/pages/tutorials/perform-external-action.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Atul-Butola <[email protected]>
1 parent 5f08057 commit e7864b7

File tree

1 file changed

+25
-61
lines changed

1 file changed

+25
-61
lines changed

fern/docs/pages/tutorials/perform-external-action.mdx

Lines changed: 25 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
## Introduction
22

3-
In this tutorial, you'll lean how to develop a snap-in that mirrors an issue from
4-
DevRev to GitHub. This requires addition of a command that can be run from
5-
the **Discussions** tab of an issue in DevRev, which creates an issue in GitHub.
3+
In this tutorial, you learn how to develop a snap-in that mirrors an issue from DevRev to GitHub. This requires addition of a command that can be run from the **Discussions** tab of an issue in DevRev, which creates an issue in GitHub.
64

75
## Background context
86

@@ -24,8 +22,8 @@ the **Discussions** tab of an issue in DevRev, which creates an issue in GitHub.
2422

2523
### Installation guide
2624

27-
- Install [DevRev CLI](/snapin-development/references/install-dev-rev-cli)
28-
- Install [jq](https://stedolan.github.io/jq)
25+
- Install [DevRev CLI](/snapin-development/references/cli-install)
26+
- Install [jq](https://stedolan.github.io/jq).
2927
- Install [DevRev SDK](https://www.npmjs.com/package/@devrev/typescript-sdk?activeTab=readme)
3028

3129
<Callout intent="info">
@@ -42,25 +40,17 @@ devrev snap_in_version init
4240

4341
#### Trigger
4442

45-
To initiate the process of creating a GitHub issue directly from a DevRev issue,
46-
a trigger mechanism is essential. In this context, the implementation involves
47-
the introduction of a specialized command. This command is designed to be
48-
executed exclusively from the discussion section of a DevRev issue, serving as
49-
the catalyst for replicating the issue on GitHub.
43+
To initiate the process of creating a GitHub issue directly from a DevRev issue, a trigger mechanism is essential. In this context, the implementation involves the introduction of a specialized command. This command is designed to be executed exclusively from the discussion section of a DevRev issue, serving as the catalyst for replicating the issue on GitHub.
5044

5145
#### Action
5246

53-
The primary action involves leveraging the issue creation API provided by
54-
GitHub. This API is utilized to create the GitHub issue seamlessly from the
55-
corresponding issue in DevRev.
47+
The primary action involves leveraging the issue creation API provided by GitHub. This API is utilized to create the GitHub issue seamlessly from the corresponding issue in DevRev.
5648

5749
### Creating the snap-in
5850

5951
#### Updating the manifest
6052

61-
To outline the structure of the snap-in, the initial step is to define key
62-
attributes in the snap-in's manifest. Begin by specifying the name, description,
63-
and account display name for the snap-in.
53+
To outline the structure of the snap-in, the initial step is to define key attributes in the snap-in's manifest. Begin by specifying the name, description, and account display name for the snap-in.
6454

6555
```yml
6656
version: "2"
@@ -73,9 +63,7 @@ service_account:
7363
7464
### Keyrings
7565
76-
To facilitate authentication for our API calls, the initial step involves
77-
creating a Personal Access Token (PAT) in GitHub. This PAT can be stored as a
78-
[connection](/snapin-development/references/keyrings) within DevRev. Subsequently, this
66+
To facilitate authentication for our API calls, the initial step involves creating a Personal Access Token (PAT) in GitHub. This PAT can be stored as a [connection](/snapin-development/references/keyrings) within DevRev. Subsequently, this
7967
connection is employed within our snap-in in the form of keyrings.
8068
8169
```yml
@@ -90,21 +78,17 @@ keyrings:
9078
9179
### Functions and commands
9280
93-
Having established the foundational configurations, the subsequent step is to
94-
define the functions and commands responsible for orchestrating the core logic
95-
of the snap-in.
81+
Having established the foundational configurations, the subsequent step is to define the functions and commands responsible for orchestrating the core logic of the snap-in.
9682
9783
```yaml
9884
functions:
9985
- name: command_handler
10086
description: Function to create a GitHub issue
10187
```
10288
103-
The command clearly states where you can use it. For example, in the
104-
**Discussions** tab of issues.
89+
The command states where you can use it. For example, in the **Discussions** tab of issues.
10590
106-
It also explains the different situations and
107-
ways in which you can make use of this command.
91+
It also explains the different situations and ways in which you can make use of this command.
10892
10993
```yml
11094
commands:
@@ -119,14 +103,12 @@ commands:
119103
function: command_handler
120104
```
121105
122-
To utilize this command, execute `/gh_issue OrgName RepoName` in the **Discussions**
123-
tab of the issue. Within the function logic, validations are implemented to
124-
ensure the correctness of both the organization name (`OrgName`) and repository
106+
To utilize this command, execute `/gh_issue OrgName RepoName` in the **Discussions** tab of the issue. Within the function logic, validations are implemented to ensure the correctness of both the organization name (`OrgName`) and repository
125107
name (`RepoName`) before proceeding with the issue creation.
126108

127109
### Function logic
128110

129-
After creating the manifest and establishing the snap-in's logic, the next step is to define the function logic that handles business logic. Once you understand the payload structure of a command, you can proceed with its implementation.
111+
After creating the manifest and establishing the snap-in's logic, the next step is to define the function logic that handles the business logic. Once you understand the payload structure of a command, you can proceed with its implementation.
130112

131113
To proceed, define the handler function for command events.
132114

@@ -136,9 +118,7 @@ const handleEvent = async (event: any) => {
136118
};
137119
```
138120

139-
Within this handler, the initial step involves extracting the GitHub token
140-
provided as input in the keyring. Subsequently, the [Octokit](https://github.com/octokit/octokit.js), responsible for
141-
managing GitHub API requests, is initialized:
121+
Within this handler, the initial step involves extracting the GitHub token provided as input in the keyring. Subsequently, the [Octokit](https://github.com/octokit/octokit.js), responsible for managing GitHub API requests, is initialized:
142122

143123
```ts
144124
const githubPAT = event.input_data.keyrings.github_connection;
@@ -148,8 +128,7 @@ const octokit = new Octokit({
148128
```
149129

150130
To facilitate authentication for DevRev API calls, a DevRev token is required.
151-
The initialization process for the DevRev SDK involves using the received
152-
endpoint.
131+
The initialization process for the DevRev SDK involves using the received endpoint.
153132

154133
```ts
155134
const devrevToken = event.context.secrets.service_account_token;
@@ -163,8 +142,8 @@ const devrevSDK = client.setup({
163142
With the SDKs successfully initialized, the next step is to invoke the necessary
164143
APIs.
165144

166-
As a preliminary step, the required fields for creating a GitHub Issue, namely
167-
**title** and **body**, need to be extracted. These details are sourced from the issue.
145+
As a preliminary step, the required fields for creating a GitHub Issue, namely **title** and **body**, need to be extracted. These details are sourced from the issue.
146+
168147
To facilitate this, introduce a function defined for this specific purpose:
169148

170149
```ts
@@ -190,8 +169,7 @@ const getIssueDetails = async (workId: string, devrevSDK: any) => {
190169
};
191170
```
192171

193-
Now, the function can be called within the handler function to obtain the
194-
necessary issue details::
172+
Now, the function can be called within the handler function to obtain the necessary issue details::
195173

196174
```ts
197175
const workId = event.payload.source_id;
@@ -230,9 +208,7 @@ const verifyOrgName = async (orgName: string, octokit: Octokit) => {
230208
};
231209
```
232210

233-
Similarly, the
234-
[GET Repository](https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#get-a-repository)
235-
is used to validate whether the entered repository name is correct.
211+
Similarly, the [GET Repository](https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#get-a-repository) is used to validate whether the entered repository name is correct.
236212

237213
```ts
238214
const verifyRepoName = async (
@@ -255,9 +231,7 @@ const verifyRepoName = async (
255231
};
256232
```
257233

258-
After completing all the necessary verifications, the
259-
[POST create issue](https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#create-an-issue)
260-
can be invoked to create a new issue.
234+
After completing all the necessary verifications, the [POST create issue](https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#create-an-issue) can be invoked to create a new issue.
261235

262236
```ts
263237
const createGitHubIssue = async (
@@ -287,34 +261,24 @@ The completion of functional logic is a key milestone in the process. After layi
287261

288262
### Deploying the snap-in to your organization
289263

290-
Once the code has been validated, the next steps involve creating the snap-in
291-
version and subsequently creating the snap-in itself. Before installing the
292-
snap-in, it's essential to set up a GitHub Personal Access Token (PAT) and add
293-
it to the connections in DevRev as a snap-in secret. Ensure that the secret is
294-
shared within the organization so that the snap-in can utilize it.
264+
Once the code has been validated, the next steps involve creating the snap-in version and subsequently creating the snap-in itself. Before installing the snap-in, it's essential to set up a GitHub Personal Access Token (PAT) and add it to the connections in DevRev as a snap-in secret. Ensure that the secret is shared within the organization so that the snap-in can utilize it.
295265

296266
Follow these steps to install the snap-in in your organization:
297267

298-
#### Step 1: Create a GitHub personal access token
268+
#### Step 1: Create a GitHub personal access token
299269

300-
Generate a GitHub Personal Access Token (PAT) by following the steps outlined in the
301-
[GitHub documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
270+
Generate a GitHub Personal Access Token (PAT) by following the steps outlined in the [GitHub documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
302271

303272
#### Step 2: Add PAT to DevRev connections
304273

305-
Add the generated PAT as a snap-in secret in DevRev. This secret will be used
306-
during the installation of the snap-in. Ensure that the secret is shared within
307-
the organization to allow the snap-in to access it.
274+
Add the generated PAT as a snap-in secret in DevRev. This secret is used during the installation of the snap-in. Ensure that the secret is shared within the organization to allow the snap-in to access it.
308275

309276
#### Step 3: Install the snap-in
310277

311-
During the installation of the snap-in, utilize the shared secret to
312-
authenticate and connect with GitHub. This ensures that the snap-in has the
313-
necessary permissions to interact with GitHub APIs.
278+
During the installation of the snap-in, utilize the shared secret to authenticate and connect with GitHub. This ensures that the snap-in has the necessary permissions to interact with GitHub APIs.
314279

315280
</Steps>
316281

317282
## Resources
318283

319-
The final snap-in code and manifest can be found
320-
[here](https://github.com/devrev/snap-in-examples/tree/main/9-external-action).
284+
The final snap-in code and manifest can be found [here](https://github.com/devrev/snap-in-examples/tree/main/9-external-action).

0 commit comments

Comments
 (0)