mirror of
				https://gitea.com/actions/setup-node.git
				synced 2025-10-29 15:52:42 +08:00 
			
		
		
		
	Add auth
This commit is contained in:
		
							
								
								
									
										48
									
								
								node_modules/@actions/github/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								node_modules/@actions/github/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
# `@actions/github`
 | 
			
		||||
 | 
			
		||||
> A hydrated Octokit client.
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
Returns an [Octokit SDK] client. See https://octokit.github.io/rest.js 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.
 | 
			
		||||
const myToken = core.getInput('myToken');
 | 
			
		||||
 | 
			
		||||
const octokit = new github.GitHub(myToken);
 | 
			
		||||
 | 
			
		||||
const pulls = await octokit.pulls.get({
 | 
			
		||||
    owner: 'octokit',
 | 
			
		||||
    repo: 'rest.js',
 | 
			
		||||
    pull_number: 123,
 | 
			
		||||
    mediaType: {
 | 
			
		||||
      format: 'diff'
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
console.log(pulls);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
You can also make GraphQL requests:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
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({
 | 
			
		||||
  ...context.repo,
 | 
			
		||||
  title: 'New issue!',
 | 
			
		||||
  body: 'Hello Universe!'
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										26
									
								
								node_modules/@actions/github/lib/context.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								node_modules/@actions/github/lib/context.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
import { WebhookPayload } from './interfaces';
 | 
			
		||||
export declare class Context {
 | 
			
		||||
    /**
 | 
			
		||||
     * Webhook payload object that triggered the workflow
 | 
			
		||||
     */
 | 
			
		||||
    payload: WebhookPayload;
 | 
			
		||||
    eventName: string;
 | 
			
		||||
    sha: string;
 | 
			
		||||
    ref: string;
 | 
			
		||||
    workflow: string;
 | 
			
		||||
    action: string;
 | 
			
		||||
    actor: string;
 | 
			
		||||
    /**
 | 
			
		||||
     * Hydrate the context from the environment
 | 
			
		||||
     */
 | 
			
		||||
    constructor();
 | 
			
		||||
    readonly issue: {
 | 
			
		||||
        owner: string;
 | 
			
		||||
        repo: string;
 | 
			
		||||
        number: number;
 | 
			
		||||
    };
 | 
			
		||||
    readonly repo: {
 | 
			
		||||
        owner: string;
 | 
			
		||||
        repo: string;
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										38
									
								
								node_modules/@actions/github/lib/context.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								node_modules/@actions/github/lib/context.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
/* eslint-disable @typescript-eslint/no-require-imports */
 | 
			
		||||
class Context {
 | 
			
		||||
    /**
 | 
			
		||||
     * Hydrate the context from the environment
 | 
			
		||||
     */
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.payload = process.env.GITHUB_EVENT_PATH
 | 
			
		||||
            ? require(process.env.GITHUB_EVENT_PATH)
 | 
			
		||||
            : {};
 | 
			
		||||
        this.eventName = process.env.GITHUB_EVENT_NAME;
 | 
			
		||||
        this.sha = process.env.GITHUB_SHA;
 | 
			
		||||
        this.ref = process.env.GITHUB_REF;
 | 
			
		||||
        this.workflow = process.env.GITHUB_WORKFLOW;
 | 
			
		||||
        this.action = process.env.GITHUB_ACTION;
 | 
			
		||||
        this.actor = process.env.GITHUB_ACTOR;
 | 
			
		||||
    }
 | 
			
		||||
    get issue() {
 | 
			
		||||
        const payload = this.payload;
 | 
			
		||||
        return Object.assign({}, this.repo, { number: (payload.issue || payload.pullRequest || payload).number });
 | 
			
		||||
    }
 | 
			
		||||
    get repo() {
 | 
			
		||||
        if (process.env.GITHUB_REPOSITORY) {
 | 
			
		||||
            const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
 | 
			
		||||
            return { owner, repo };
 | 
			
		||||
        }
 | 
			
		||||
        if (this.payload.repository) {
 | 
			
		||||
            return {
 | 
			
		||||
                owner: this.payload.repository.owner.login,
 | 
			
		||||
                repo: this.payload.repository.name
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
        throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.Context = Context;
 | 
			
		||||
//# sourceMappingURL=context.js.map
 | 
			
		||||
							
								
								
									
										1
									
								
								node_modules/@actions/github/lib/context.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/@actions/github/lib/context.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;AAGA,0DAA0D;AAE1D,MAAa,OAAO;IAalB;;OAEG;IACH;QACE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAA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ACnF,CAAA;IACH,CAAC;CACF;AAtDD,0BAsDC"}
 | 
			
		||||
							
								
								
									
										8
									
								
								node_modules/@actions/github/lib/github.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								node_modules/@actions/github/lib/github.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
import { GraphQlQueryResponse, Variables } from '@octokit/graphql';
 | 
			
		||||
import Octokit from '@octokit/rest';
 | 
			
		||||
import * as Context from './context';
 | 
			
		||||
export declare const context: Context.Context;
 | 
			
		||||
export declare class GitHub extends Octokit {
 | 
			
		||||
    graphql: (query: string, variables?: Variables) => Promise<GraphQlQueryResponse>;
 | 
			
		||||
    constructor(token: string);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										29
									
								
								node_modules/@actions/github/lib/github.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								node_modules/@actions/github/lib/github.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
			
		||||
    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
			
		||||
};
 | 
			
		||||
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 = __importDefault(require("@octokit/rest"));
 | 
			
		||||
const Context = __importStar(require("./context"));
 | 
			
		||||
// We need this in order to extend Octokit
 | 
			
		||||
rest_1.default.prototype = new rest_1.default();
 | 
			
		||||
exports.context = new Context.Context();
 | 
			
		||||
class GitHub extends rest_1.default {
 | 
			
		||||
    constructor(token) {
 | 
			
		||||
        super({ auth: `token ${token}` });
 | 
			
		||||
        this.graphql = graphql_1.defaults({
 | 
			
		||||
            headers: { authorization: `token ${token}` }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
exports.GitHub = GitHub;
 | 
			
		||||
//# sourceMappingURL=github.js.map
 | 
			
		||||
							
								
								
									
										1
									
								
								node_modules/@actions/github/lib/github.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/@actions/github/lib/github.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
{"version":3,"file":"github.js","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gGAAgG;AAChG,8CAA0E;AAC1E,yDAAmC;AACnC,mDAAoC;AAEpC,0CAA0C;AAC1C,cAAO,CAAC,SAAS,GAAG,IAAI,cAAO,EAAE,CAAA;AAEpB,QAAA,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,CAAA;AAE5C,MAAa,MAAO,SAAQ,cAAO;IAMjC,YAAY,KAAa;QACvB,KAAK,CAAC,EAAC,IAAI,EAAE,SAAS,KAAK,EAAE,EAAC,CAAC,CAAA;QAC/B,IAAI,CAAC,OAAO,GAAG,kBAAQ,CAAC;YACtB,OAAO,EAAE,EAAC,aAAa,EAAE,SAAS,KAAK,EAAE,EAAC;SAC3C,CAAC,CAAA;IACJ,CAAC;CACF;AAZD,wBAYC"}
 | 
			
		||||
							
								
								
									
										36
									
								
								node_modules/@actions/github/lib/interfaces.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								node_modules/@actions/github/lib/interfaces.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
export interface PayloadRepository {
 | 
			
		||||
    [key: string]: any;
 | 
			
		||||
    full_name?: string;
 | 
			
		||||
    name: string;
 | 
			
		||||
    owner: {
 | 
			
		||||
        [key: string]: any;
 | 
			
		||||
        login: string;
 | 
			
		||||
        name?: string;
 | 
			
		||||
    };
 | 
			
		||||
    html_url?: string;
 | 
			
		||||
}
 | 
			
		||||
export interface WebhookPayload {
 | 
			
		||||
    [key: string]: any;
 | 
			
		||||
    repository?: PayloadRepository;
 | 
			
		||||
    issue?: {
 | 
			
		||||
        [key: string]: any;
 | 
			
		||||
        number: number;
 | 
			
		||||
        html_url?: string;
 | 
			
		||||
        body?: string;
 | 
			
		||||
    };
 | 
			
		||||
    pull_request?: {
 | 
			
		||||
        [key: string]: any;
 | 
			
		||||
        number: number;
 | 
			
		||||
        html_url?: string;
 | 
			
		||||
        body?: string;
 | 
			
		||||
    };
 | 
			
		||||
    sender?: {
 | 
			
		||||
        [key: string]: any;
 | 
			
		||||
        type: string;
 | 
			
		||||
    };
 | 
			
		||||
    action?: string;
 | 
			
		||||
    installation?: {
 | 
			
		||||
        id: number;
 | 
			
		||||
        [key: string]: any;
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										4
									
								
								node_modules/@actions/github/lib/interfaces.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								node_modules/@actions/github/lib/interfaces.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
/* eslint-disable @typescript-eslint/no-explicit-any */
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
//# sourceMappingURL=interfaces.js.map
 | 
			
		||||
							
								
								
									
										1
									
								
								node_modules/@actions/github/lib/interfaces.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/@actions/github/lib/interfaces.js.map
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA,uDAAuD"}
 | 
			
		||||
							
								
								
									
										68
									
								
								node_modules/@actions/github/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								node_modules/@actions/github/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
{
 | 
			
		||||
  "_from": "file:toolkit\\actions-github-0.0.0.tgz",
 | 
			
		||||
  "_id": "@actions/github@0.0.0",
 | 
			
		||||
  "_inBundle": false,
 | 
			
		||||
  "_integrity": "sha512-CByX5VIagC5BqGwsHD9Qt5MfN+H6GDC9qQl+MIUipaHTc89sUG/vAY/xQDS9vxuuRwrxbdERwKO3dR6U1BSziw==",
 | 
			
		||||
  "_location": "/@actions/github",
 | 
			
		||||
  "_phantomChildren": {},
 | 
			
		||||
  "_requested": {
 | 
			
		||||
    "type": "file",
 | 
			
		||||
    "where": "C:\\Users\\Administrator\\Documents\\setup-node",
 | 
			
		||||
    "raw": "@actions/github@file:toolkit/actions-github-0.0.0.tgz",
 | 
			
		||||
    "name": "@actions/github",
 | 
			
		||||
    "escapedName": "@actions%2fgithub",
 | 
			
		||||
    "scope": "@actions",
 | 
			
		||||
    "rawSpec": "file:toolkit/actions-github-0.0.0.tgz",
 | 
			
		||||
    "saveSpec": "file:toolkit\\actions-github-0.0.0.tgz",
 | 
			
		||||
    "fetchSpec": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-github-0.0.0.tgz"
 | 
			
		||||
  },
 | 
			
		||||
  "_requiredBy": [
 | 
			
		||||
    "#USER",
 | 
			
		||||
    "/"
 | 
			
		||||
  ],
 | 
			
		||||
  "_resolved": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-github-0.0.0.tgz",
 | 
			
		||||
  "_shasum": "d9a87b3682d66d032fffcaff1adcdb2decd92b81",
 | 
			
		||||
  "_spec": "@actions/github@file:toolkit/actions-github-0.0.0.tgz",
 | 
			
		||||
  "_where": "C:\\Users\\Administrator\\Documents\\setup-node",
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/actions/toolkit/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "bundleDependencies": false,
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@octokit/graphql": "^2.0.1",
 | 
			
		||||
    "@octokit/rest": "^16.15.0"
 | 
			
		||||
  },
 | 
			
		||||
  "deprecated": false,
 | 
			
		||||
  "description": "Actions github lib",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "jest": "^24.7.1"
 | 
			
		||||
  },
 | 
			
		||||
  "directories": {
 | 
			
		||||
    "lib": "lib",
 | 
			
		||||
    "test": "__tests__"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "lib"
 | 
			
		||||
  ],
 | 
			
		||||
  "homepage": "https://github.com/actions/toolkit/tree/master/packages/github",
 | 
			
		||||
  "keywords": [
 | 
			
		||||
    "github",
 | 
			
		||||
    "actions"
 | 
			
		||||
  ],
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "main": "lib/github.js",
 | 
			
		||||
  "name": "@actions/github",
 | 
			
		||||
  "publishConfig": {
 | 
			
		||||
    "access": "public"
 | 
			
		||||
  },
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "git+https://github.com/actions/toolkit.git"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "tsc",
 | 
			
		||||
    "test": "jest",
 | 
			
		||||
    "tsc": "tsc"
 | 
			
		||||
  },
 | 
			
		||||
  "version": "0.0.0"
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user