How to use @octokit/rest.activity:
30 31 32 33 34 35 36 37 38 39
return 0; } function getOrgPublicActivity(org, per_page = 100) { return new Promise((resolve, reject) => { octokit.activity.getEventsForOrg({org, per_page}) .then(data => { resolve(data.data.map(item => { if(item.payload) { delete item.payload;
How to use @octokit/rest.users:
16 17 18 19 20 21 22 23 24 25
} async userOrgs() { try { let result = await octokit.users.getOrgs({}) return result } catch (error) { console.log(error) }
How to use @octokit/rest.search:
33 34 35 36 37 38 39 40 41 42
try { const options = method.endpoint.merge(queryObject) const data = await octokit.paginate( options, (response) => { return (method === octokit.search.issues) ? response.data.items : response.data } ); return data; } catch(e) {
How to use @octokit/rest.teams:
97 98 99 100 101 102 103 104 105
type: 'oauth', token: githubAccessToken, }); const teams = await paginate( octokit.teams.list, { org: githubOrg }, logger );
How to use @octokit/rest.paginate:
19 20 21 22 23 24 25 26 27
for (const repository of res.data) { const opt = octokit.repos.listHooks.endpoint.merge({ owner: repository.owner.login, repo: repository.name, }) for await (const res of octokit.paginate.iterator(opt)) { if (res.status !== 200) { process.exit(-1) }
How to use @octokit/rest.issues:
29 30 31 32 33 34 35
repo, number: prNumber, }); const commentId = data.find(comment => comment.body.includes(reportId)).id; return octokit.issues.editComment({ owner, repo, comment_id: commentId, body }); };
How to use @octokit/rest.authenticate:
0 1 2 3 4 5 6 7 8
const parse = require('parse-github-url'); const octokit = require('@octokit/rest')(); const {execSync} = require('child_process'); module.exports = async function ({change, branch}) { octokit.authenticate({ type: 'token', token: process.env.GITHUB_TOKEN });
7
16
77
See more examples
How to use @octokit/rest.getNextPage:
GitHub: ValeraS/automation
36 37 38 39 40 41 42 43 44 45
let done = false; // will be true when lastPR is seen in paginated results let response = await method(methodProps); let { data } = response; data = prFilter(data, firstPR, lastPR, prPropsToGet); while (octokit.hasNextPage(response) && !done ) { response = await octokit.getNextPage(response); let dataFiltered = prFilter(response.data, firstPR, lastPR, prPropsToGet); data = data.concat(dataFiltered); } return data;
How to use @octokit/rest.pullRequests:
7 8 9 10 11 12 13 14 15 16
token: process.env.GITHUB_TOKEN }); const {owner, name: repo, filepath: number} = parse(change); const prData = (await octokit.pullRequests.get({owner, repo, number})).data; const prReviews = (await octokit.pullRequests.getReviews({owner, repo, number})).data; const prPatch = (await octokit.pullRequests.get({owner, repo, number, headers: {accept: 'application/vnd.github.v3.patch'}})).data; const prSlug = branch.replace(/^release-/, ''); const prBranch = `backport-${prSlug}-${number}-${prData.head.ref}`;
7
16
77
See more examples
How to use @octokit/rest.repos:
GitHub: mapbox/secret-shield
19 20 21 22 23 24 25 26 27 28
return reject(err); }); } return new Promise((resolve, reject) => { octokit.repos.getForOrg(options).then((response) => { repos = repos.concat(parseRepos(response)); getRemanding(response, resolve, reject); }).catch((err) => { return reject(err);
13
34
74
See more examples
How to use @octokit/rest.Octokit:
GitHub: newrelic/node-newrelic
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 {
365
911
48
See more examples