Skip to content

Commit

Permalink
Get token from input in doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny McCormick authored Jul 31, 2019
1 parent 5218a83 commit 4a7f214
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 core = require('@actions/core');
// 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({
owner: 'octokit',
Expand All @@ -21,27 +22,27 @@ const pulls = await octokit.pulls.get({
mediaType: {
format: 'diff'
}
})
});
console.log(pulls)
console.log(pulls);
```

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:

```
const github = require('@actions/github');
const context = github.context
const context = github.context;
const newIssue = await octokit.issues.create({
...context.repo,
title: 'New issue!',
body: 'Hello Universe!'
})
```
});
```

0 comments on commit 4a7f214

Please sign in to comment.