How to use the @octokit/rest.Octokit function in @octokit/rest

To help you get started, we’ve selected a few @octokit/rest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / azure-pipelines-agent / release / createReleaseBranch.js View on Github external
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const tl = require('azure-pipelines-task-lib/task');
const util = require('./util');

const { Octokit } = require("@octokit/rest");

const OWNER = 'microsoft';
const REPO  = 'azure-pipelines-agent';
const GIT = 'git';
const VALID_RELEASE_RE = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/;
const octokit = new Octokit({}); // only read-only operations, no need to auth

process.env.EDITOR = process.env.EDITOR === undefined ? 'code --wait' : process.env.EDITOR;

var opt = require('node-getopt').create([
    ['',  'dryrun',               'Dry run only, do not actually commit new release'],
    ['',  'derivedFrom=version',  'Used to get PRs merged since this release was created', 'latest'],
    ['',  'branch=branch',        'Branch to select PRs merged into', 'master'],
    ['h', 'help',                 'Display this help'],
  ])
  .setHelp(
    'Usage: node createReleaseBranch.js [OPTION] \n' +
    '\n' +
    '[[OPTIONS]]\n'
  )
  .bindHelp()     // bind option 'help' to default action
  .parseSystem(); // parse command line
github microsoft / azure-pipelines-agent / release / mkrelease.js View on Github external
const fs = require('fs');
const cp = require('child_process');
const naturalSort = require('natural-sort');
const path = require('path');

const { Octokit } = require("@octokit/rest");
const owner = 'microsoft';
const repo  = 'azure-pipelines-agent';
const octokit = new Octokit({}); // only read-only operations, no need to auth

const INTEGRATION_DIR = path.join(__dirname, '..', '_layout', 'integrations');
const GIT = 'git';
const VALID_RELEASE_RE = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/;
const GIT_RELEASE_RE = /([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/;


process.env.EDITOR = process.env.EDITOR === undefined ? 'code --wait' : process.env.EDITOR;

var opt = require('node-getopt').create([
    ['',  'dryrun',               'Dry run only, do not actually commit new release'],
    ['',  'unattended',           'This is run in a pipeline, so do not prompt for confirmation of release notes'],
    ['',  'derivedFrom=version',  'Used to get PRs merged since this release was created', 'latest'],
    ['',  'branch=branch',        'Branch to select PRs merged into', 'master'],
    ['h', 'help',                 'Display this help'],
  ])
github YOCKOW / Action-setup-swift / node_modules / @actions / github / lib / github.js View on Github external
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
const graphql_1 = require("@octokit/graphql");
const rest_1 = require("@octokit/rest");
const Context = __importStar(require("./context"));
const httpClient = __importStar(require("@actions/http-client"));
// We need this in order to extend Octokit
rest_1.Octokit.prototype = new rest_1.Octokit();
exports.context = new Context.Context();
class GitHub extends rest_1.Octokit {
    constructor(token, opts) {
        super(GitHub.getOctokitOptions(GitHub.disambiguate(token, opts)));
        this.graphql = GitHub.getGraphQL(GitHub.disambiguate(token, opts));
    }
    /**
     * Disambiguates the constructor overload parameters
     */
    static disambiguate(token, opts) {
        return [
            typeof token === 'string' ? token : '',
            typeof token === 'object' ? token : opts || {}
        ];
    }
    static getOctokitOptions(args) {
github konveyor / move2kube / assets / js / internalpages / releaseui.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
        const workflow_filename = 'publish.yml';
        const branch_to_run_on = 'main';
        try {
            if (!PA_TOKEN) {
                return alert('the personal access token is invalid.');
            }
            const octokit = new rest_1.Octokit({ auth: PA_TOKEN });
            const resp = yield octokit.actions.createWorkflowDispatch({
                owner,
                repo,
                workflow_id: workflow_filename,
                ref: branch_to_run_on,
                inputs: { owner_repo_ids: JSON.stringify(owner_repo_ids) },
            });
            console.log(resp);
            document.querySelector('#publish-release-release-drafts').classList.add('hidden');
            const ele = document.querySelector('#publish-release-result-success');
            ele.textContent = `Success!! Status: ${resp.status}`;
            ele.classList.remove('hidden');
            document.querySelector('#publish-release-result').classList.remove('hidden');
        }
        catch (err) {
            console.error(err);
github konveyor / move2kube / assets / js / internalpages / releaseui.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
        const octokit = new rest_1.Octokit({ auth: PA_TOKEN });
        try {
            const promises = owner_repo_ids.map(owner_repo_id => octokit.repos.deleteRelease(owner_repo_id));
            yield Promise.all(promises);
            document.querySelector('#publish-release-release-drafts').classList.add('hidden');
            const ele = document.querySelector('#publish-release-result-success');
            ele.textContent = `Success!!`;
            ele.classList.remove('hidden');
            document.querySelector('#publish-release-result').classList.remove('hidden');
        }
        catch (err) {
            console.error(err);
            document.querySelector('#publish-release-release-drafts').classList.add('hidden');
            const ele = document.querySelector('#publish-release-result-error');
            ele.textContent = err;
            ele.classList.remove('hidden');
            document.querySelector('#publish-release-result').classList.remove('hidden');