mirror of https://github.com/actions/toolkit
[@actions/github] Fix code example, add syntax highlighting (#43)
* [@actions/github] Fix code example, add syntax highlighting * [@actions/github] add link to @octkit/graphql API * [@octokit/github] moar syntax highlighting in READMEpull/44/head
parent
a40bce7c8d
commit
aec0ef46e4
|
@ -4,9 +4,9 @@
|
|||
|
||||
## Usage
|
||||
|
||||
Returns an [Octokit SDK] client. See https://octokit.github.io/rest.js for the API.
|
||||
Returns an Octokit client. See https://octokit.github.io/rest.js for the API.
|
||||
|
||||
```
|
||||
```js
|
||||
const github = require('@actions/github');
|
||||
const core = require('@actions/core');
|
||||
|
||||
|
@ -15,7 +15,7 @@ const myToken = core.getInput('myToken');
|
|||
|
||||
const octokit = new github.GitHub(myToken);
|
||||
|
||||
const pulls = await octokit.pulls.get({
|
||||
const { data: pullRequest } = await octokit.pulls.get({
|
||||
owner: 'octokit',
|
||||
repo: 'rest.js',
|
||||
pull_number: 123,
|
||||
|
@ -24,18 +24,18 @@ const pulls = await octokit.pulls.get({
|
|||
}
|
||||
});
|
||||
|
||||
console.log(pulls);
|
||||
console.log(pullRequest);
|
||||
```
|
||||
|
||||
You can also make GraphQL requests:
|
||||
You can also make GraphQL requests. See https://github.com/octokit/graphql.js for the API.
|
||||
|
||||
```
|
||||
```js
|
||||
const result = await octokit.graphql(query, variables);
|
||||
```
|
||||
|
||||
Finally, you can get the context of the current action:
|
||||
|
||||
```
|
||||
```js
|
||||
const github = require('@actions/github');
|
||||
|
||||
const context = github.context;
|
||||
|
|
Loading…
Reference in New Issue