npm install @octokit/rest
const { Octokit } = require('@octokit/rest'); const octokit = new Octokit(); // Compare: https://developer.github.com/v3/repos/#list-organization-repositories octokit.repos .listForOrg({ org: 'octokit', type: 'public', }) .then(({ data }) => { // handle data });
const { Octokit } = require('@octokit/rest'); const { Base64 } = require('js-base64'); const fs = require('fs'); if (process.env.MODE !== 'production') { require('dotenv').config(); } const octokit = new Octokit({ auth: process.env.GITHUB_ACCESS_TOKEN, }); const content = fs.readFileSync('file/to/path', 'utf-8'); const fileOutput = Base64.encode(content); const { data } = await octokit.repos.createOrUpdateFileContents({ owner: 'okeeffed', repo: 'octokit-create-file-example', path: 'OUTPUT.md', message: 'feat: Added OUTPUT.md programatically', content: contentEncoded, committer: { name: `Octokit Bot`, email: 'hello@dennisokeeffe.com', }, author: { name: 'Octokit Bot', email: 'hello@dennisokeeffe.com', }, });