How to use the Octokit function from @octokit/rest

Find comprehensive JavaScript @octokit/rest.Octokit code examples handpicked from public code repositorys.

8
9
10
11
12
13
14
15
16
17

if (!process.env.GITHUB_TOKEN) {
  console.log('GITHUB_TOKEN recommended to be set in ENV')
}

const octokit = new Octokit({
  auth: process.env.GITHUB_TOKEN
})

class Github {
fork icon365
star icon911
watch icon48

17
18
19
20
21
22
23
24
25
26
  process.exit();
}

const [owner, repo] = GITHUB_REPOSITORY.split('/');
const octokitDefaults = { owner, repo, pull_number };
const octokit = new Octokit({ auth });

/**
 * Do a diff on the current PR against main
 *
fork icon122
star icon222
watch icon195

9
10
11
12
13
14
15
16
17
18

class GitHubRemoteService extends RemoteService {
    constructor ({ auth, baseUrl }, resourceCache) {
        super(resourceCache);

        this.octokit = new Octokit({
            auth,
            baseUrl,
            userAgent,
            request: {
fork icon42
star icon171
watch icon14

1
2
3
4
5
6
7
8
9
const { Octokit } = require('@octokit/rest');

let github;

function githubAuthenticate() {
  github = new Octokit({
    auth: process.env.GITHUB_TOKEN,
  });
}
fork icon13
star icon124
watch icon4

28
29
30
31
32
33
34
35
36
37
function init() {
	// We will built a userOctokit IF a password (token) is given
//	if (!configuration.getOption("app-mode")) {
	if (configuration.getOption('password') != undefined) {
		const authString = "token " + configuration.getOption('password');
		userOctokit = new Octokit({
			userAgent: 'yoda-restapi',
			baseUrl: configuration.getOption('baseurl'),
			log: logger,
			auth: authString
fork icon23
star icon90
watch icon13

+ 9 other calls in file

18
19
20
21
22
23
24
25
26
27

// most of the code below is no longer needed with the octokit v18

class Github {
  constructor(options = {}) {
    this.octokit=new octokitlib.Octokit()
    this.creds={}
  }

  async getCreds() {
fork icon20
star icon31
watch icon4

2
3
4
5
6
7
8
9
10
11
const fs = require('fs-extra');
const path = require('path');

async function downloadAsserts(owner, repo, out) {
    const versions = {};
    const github = new Octokit.Octokit();

    const releaseResp = await github.repos.getLatestRelease({
        owner,
        repo
fork icon2
star icon24
watch icon6

18
19
20
21
22
23
24
25
26
27
}

const LIB = ['skia', 'skparagraph', 'skshaper', 'svg', 'sktext', 'skunicode']
const ICU_DAT = 'icudtl.dat'

const CLIENT = new Octokit({
  auth: process.env.GITHUB_TOKEN,
})

async function upload() {
fork icon53
star icon0
watch icon12

-1
fork icon1
star icon0
watch icon1

+ 3 other calls in file

119
120
121
122
123
124
125
126
127
128
/**
 * GET /api/github
 * GitHub API Example.
 */
exports.getGithub = async (req, res, next) => {
  const github = new Octokit();
  try {
    const { data: repo } = await github.repos.get({ owner: 'sahat', repo: 'hackathon-starter' });
    res.render('api/github', {
      title: 'GitHub API',
fork icon0
star icon0
watch icon1

+ 4 other calls in file