mirror of https://github.com/actions/toolkit
Get token from input in doc
parent
5218a83722
commit
4a7f2143e6
|
@ -8,11 +8,12 @@ Returns an [Octokit SDK] client. See https://octokit.github.io/rest.js for the A
|
||||||
|
|
||||||
```
|
```
|
||||||
const github = require('@actions/github');
|
const github = require('@actions/github');
|
||||||
|
const core = require('@actions/core');
|
||||||
|
|
||||||
// This should be a token with access to your repository scoped in as a secret.
|
// This should be a token with access to your repository scoped in as a secret.
|
||||||
const myToken = process.env.GITHUB_TOKEN
|
const myToken = core.getInput('myToken');
|
||||||
|
|
||||||
const octokit = new github.GitHub(myToken)
|
const octokit = new github.GitHub(myToken);
|
||||||
|
|
||||||
const pulls = await octokit.pulls.get({
|
const pulls = await octokit.pulls.get({
|
||||||
owner: 'octokit',
|
owner: 'octokit',
|
||||||
|
@ -21,15 +22,15 @@ const pulls = await octokit.pulls.get({
|
||||||
mediaType: {
|
mediaType: {
|
||||||
format: 'diff'
|
format: 'diff'
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
console.log(pulls)
|
console.log(pulls);
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also make GraphQL requests:
|
You can also make GraphQL requests:
|
||||||
|
|
||||||
```
|
```
|
||||||
const result = await octokit.graphql(query, variables)
|
const result = await octokit.graphql(query, variables);
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, you can get the context of the current action:
|
Finally, you can get the context of the current action:
|
||||||
|
@ -37,11 +38,11 @@ Finally, you can get the context of the current action:
|
||||||
```
|
```
|
||||||
const github = require('@actions/github');
|
const github = require('@actions/github');
|
||||||
|
|
||||||
const context = github.context
|
const context = github.context;
|
||||||
|
|
||||||
const newIssue = await octokit.issues.create({
|
const newIssue = await octokit.issues.create({
|
||||||
...context.repo,
|
...context.repo,
|
||||||
title: 'New issue!',
|
title: 'New issue!',
|
||||||
body: 'Hello Universe!'
|
body: 'Hello Universe!'
|
||||||
})
|
});
|
||||||
```
|
```
|
Loading…
Reference in New Issue