mirror of https://github.com/actions/toolkit
Wrap example in async function (#157)
As someone not too familiar with async/await JavaScript, I was hung up on this for a bit. If this is too distracting from the example itself, I can understand not integrating it.pull/165/head
parent
14ac06ecd8
commit
46bd5e54fd
|
@ -10,24 +10,28 @@ Returns an Octokit client. See https://octokit.github.io/rest.js for the API.
|
||||||
const github = require('@actions/github');
|
const github = require('@actions/github');
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
|
|
||||||
// This should be a token with access to your repository scoped in as a secret.
|
async function run() {
|
||||||
// The YML workflow will need to set myToken with the GitHub Secret Token
|
// This should be a token with access to your repository scoped in as a secret.
|
||||||
// myToken: ${{ secrets.GITHUB_TOKEN }}
|
// The YML workflow will need to set myToken with the GitHub Secret Token
|
||||||
// https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret
|
// myToken: ${{ secrets.GITHUB_TOKEN }
|
||||||
const myToken = core.getInput('myToken');
|
// https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret
|
||||||
|
const myToken = core.getInput('myToken');
|
||||||
|
|
||||||
const octokit = new github.GitHub(myToken);
|
const octokit = new github.GitHub(myToken);
|
||||||
|
|
||||||
const { data: pullRequest } = await octokit.pulls.get({
|
const { data: pullRequest } = await octokit.pulls.get({
|
||||||
owner: 'octokit',
|
owner: 'octokit',
|
||||||
repo: 'rest.js',
|
repo: 'rest.js',
|
||||||
pull_number: 123,
|
pull_number: 123,
|
||||||
mediaType: {
|
mediaType: {
|
||||||
format: 'diff'
|
format: 'diff'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(pullRequest);
|
console.log(pullRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
||||||
```
|
```
|
||||||
|
|
||||||
You can pass client options (except `auth`, which is handled by the token argument), as specified by [Octokit](https://octokit.github.io/rest.js/), as a second argument to the `GitHub` constructor.
|
You can pass client options (except `auth`, which is handled by the token argument), as specified by [Octokit](https://octokit.github.io/rest.js/), as a second argument to the `GitHub` constructor.
|
||||||
|
|
Loading…
Reference in New Issue