Skip to content
Branch: master
Find file History
warrenbuckley and damccorm Update readme to show how to use the secret GITHUB_TOKEN (#131)
* Update readme to show how to use the secret GITHUB_TOKEN

* Adds in link to docs - which I feel seem to be scattered in repos & official docs
Latest commit b297969 Sep 13, 2019


A hydrated Octokit client.


Returns an Octokit client. See for the API.

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.
// The YML workflow will need to set myToken with the GitHub Secret Token
// myToken: ${{ secrets.GITHUB_TOKEN }
const myToken = core.getInput('myToken');

const octokit = new github.GitHub(myToken);

const { data: pullRequest } = await octokit.pulls.get({
    owner: 'octokit',
    repo: 'rest.js',
    pull_number: 123,
    mediaType: {
      format: 'diff'


You can pass client options (except auth, which is handled by the token argument), as specified by Octokit, as a second argument to the GitHub constructor.

You can also make GraphQL requests. See for the API.

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 newIssue = await octokit.issues.create({
  title: 'New issue!',
  body: 'Hello Universe!'
You can’t perform that action at this time.