Merge pull request #2 from actions/client-options

Add client options
This commit is contained in:
Jonathan Clem
2019-09-05 12:02:21 -04:00
committed by GitHub
25 changed files with 688 additions and 574 deletions

View File

@@ -10,6 +10,14 @@ inputs:
github-token: github-token:
description: The GitHub token used to create an authenticated client description: The GitHub token used to create an authenticated client
required: true required: true
debug:
description: Whether to tell the GitHub client to log details of its requests
default: false
user-agent:
description: An optional user-agent string
default: actions/github-script
previews:
description: A comma-separated list of API previews to accept
outputs: outputs:
result: result:
description: The return value of the script, stringified with `JSON.stringify` description: The return value of the script, stringified with `JSON.stringify`

11
main.js
View File

@@ -6,10 +6,17 @@ main().catch(handleError)
async function main() { async function main() {
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor
const script = core.getInput('script', {required: true})
const token = core.getInput('github-token', {required: true}) const token = core.getInput('github-token', {required: true})
const debug = core.getInput('debug')
const userAgent = core.getInput('user-agent')
const previews = core.getInput('previews')
const opts = {}
if (debug === 'true') opts.log = console
if (userAgent != null) opts.userAgent = userAgent
if (previews != null) opts.previews = previews.split(',')
const client = new GitHub(token, opts)
const script = core.getInput('script', {required: true})
const fn = new AsyncFunction('github', 'context', script) const fn = new AsyncFunction('github', 'context', script)
const client = new GitHub(token)
const result = await fn(client, context) const result = await fn(client, context)
core.setOutput('result', JSON.stringify(result)) core.setOutput('result', JSON.stringify(result))
} }

8
node_modules/.yarn-integrity generated vendored
View File

@@ -6,12 +6,12 @@
"flags": [], "flags": [],
"linkedModules": [], "linkedModules": [],
"topLevelPatterns": [ "topLevelPatterns": [
"@actions/core@^1.0.0", "@actions/core@^1.1.0",
"@actions/github@^1.0.0" "@actions/github@^1.1.0"
], ],
"lockfileEntries": { "lockfileEntries": {
"@actions/core@^1.0.0": "https://registry.yarnpkg.com/@actions/core/-/core-1.0.0.tgz#4a090a2e958cc300b9ea802331034d5faf42d239", "@actions/core@^1.1.0": "https://registry.yarnpkg.com/@actions/core/-/core-1.1.0.tgz#25c3aff43a20f9c5a04e2a3439898a49ba8d3625",
"@actions/github@^1.0.0": "https://registry.yarnpkg.com/@actions/github/-/github-1.0.0.tgz#5154cadd93c4b17217f56304ee27056730b8ae88", "@actions/github@^1.1.0": "https://registry.yarnpkg.com/@actions/github/-/github-1.1.0.tgz#06f34e6b0cf07eb2b3641de3e680dbfae6bcd400",
"@octokit/endpoint@^5.1.0": "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.3.2.tgz#2deda2d869cac9ba7f370287d55667be2a808d4b", "@octokit/endpoint@^5.1.0": "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.3.2.tgz#2deda2d869cac9ba7f370287d55667be2a808d4b",
"@octokit/graphql@^2.0.1": "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-2.1.3.tgz#60c058a0ed5fa242eca6f938908d95fd1a2f4b92", "@octokit/graphql@^2.0.1": "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-2.1.3.tgz#60c058a0ed5fa242eca6f938908d95fd1a2f4b92",
"@octokit/request-error@^1.0.1": "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.0.4.tgz#15e1dc22123ba4a9a4391914d80ec1e5303a23be", "@octokit/request-error@^1.0.1": "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.0.4.tgz#15e1dc22123ba4a9a4391914d80ec1e5303a23be",

View File

@@ -1,7 +1,7 @@
Copyright 2019 GitHub Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

178
node_modules/@actions/core/README.md generated vendored
View File

@@ -1,81 +1,97 @@
# `@actions/core` # `@actions/core`
> Core functions for setting results, logging, registering secrets and exporting variables across actions > Core functions for setting results, logging, registering secrets and exporting variables across actions
## Usage ## Usage
#### Inputs/Outputs #### Inputs/Outputs
You can use this library to get inputs or set outputs: You can use this library to get inputs or set outputs:
``` ```js
const core = require('@actions/core'); const core = require('@actions/core');
const myInput = core.getInput('inputName', { required: true }); const myInput = core.getInput('inputName', { required: true });
// Do stuff // Do stuff
core.setOutput('outputKey', 'outputVal'); core.setOutput('outputKey', 'outputVal');
``` ```
#### Exporting variables/secrets #### Exporting variables
You can also export variables and secrets for future steps. Variables get set in the environment automatically, while secrets must be scoped into the environment from a workflow using `{{ secret.FOO }}`. Secrets will also be masked from the logs: You can also export variables for future steps. Variables get set in the environment.
``` ```js
const core = require('@actions/core'); const core = require('@actions/core');
// Do stuff // Do stuff
core.exportVariable('envVar', 'Val'); core.exportVariable('envVar', 'Val');
core.exportSecret('secretVar', variableWithSecretValue); ```
```
#### PATH Manipulation
#### PATH Manipulation
You can explicitly add items to the path for all remaining steps in a workflow:
You can explicitly add items to the path for all remaining steps in a workflow:
```js
``` const core = require('@actions/core');
const core = require('@actions/core');
core.addPath('pathToTool');
core.addPath('pathToTool'); ```
```
#### Exit codes
#### Exit codes
You should use this library to set the failing exit code for your action:
You should use this library to set the failing exit code for your action:
```js
``` const core = require('@actions/core');
const core = require('@actions/core');
try {
try { // Do stuff
// Do stuff }
} catch (err) {
catch (err) { // setFailed logs the message and sets a failing exit code
// setFailed logs the message and sets a failing exit code core.setFailed(`Action failed with error ${err}`);
core.setFailed(`Action failed with error ${err}`); }
}
```
```
#### Logging
#### Logging
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
Finally, this library provides some utilities for logging:
```js
``` const core = require('@actions/core');
const core = require('@actions/core');
const myInput = core.getInput('input');
const myInput = core.getInput('input'); try {
try { core.debug('Inside try block');
core.debug('Inside try block');
if (!myInput) {
if (!myInput) { core.warning('myInput was not set');
core.warning('myInput wasnt set'); }
}
// Do stuff
// Do stuff }
} catch (err) {
catch (err) { core.error(`Error ${err}, action may still succeed though`);
core.error('Error ${err}, action may still succeed though'); }
} ```
```
This library can also wrap chunks of output in foldable groups.
```js
const core = require('@actions/core')
// Manually wrap output
core.startGroup('Do some function')
doSomeFunction()
core.endGroup()
// Wrap an asynchronous function call
const result = await core.group('Do something async', async () => {
const response = await doSomeHTTPRequest()
return response
})
```

View File

@@ -1,16 +1,16 @@
interface CommandProperties { interface CommandProperties {
[key: string]: string; [key: string]: string;
} }
/** /**
* Commands * Commands
* *
* Command Format: * Command Format:
* ##[name key=value;key=value]message * ##[name key=value;key=value]message
* *
* Examples: * Examples:
* ##[warning]This is the user warning message * ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definatelyNotAPassword! * ##[set-secret name=mypassword]definitelyNotAPassword!
*/ */
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void; export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
export declare function issue(name: string, message: string): void; export declare function issue(name: string, message?: string): void;
export {}; export {};

View File

@@ -1,66 +1,66 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const os = require("os"); const os = require("os");
/** /**
* Commands * Commands
* *
* Command Format: * Command Format:
* ##[name key=value;key=value]message * ##[name key=value;key=value]message
* *
* Examples: * Examples:
* ##[warning]This is the user warning message * ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definatelyNotAPassword! * ##[set-secret name=mypassword]definitelyNotAPassword!
*/ */
function issueCommand(command, properties, message) { function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message); const cmd = new Command(command, properties, message);
process.stdout.write(cmd.toString() + os.EOL); process.stdout.write(cmd.toString() + os.EOL);
} }
exports.issueCommand = issueCommand; exports.issueCommand = issueCommand;
function issue(name, message) { function issue(name, message = '') {
issueCommand(name, {}, message); issueCommand(name, {}, message);
} }
exports.issue = issue; exports.issue = issue;
const CMD_PREFIX = '##['; const CMD_PREFIX = '##[';
class Command { class Command {
constructor(command, properties, message) { constructor(command, properties, message) {
if (!command) { if (!command) {
command = 'missing.command'; command = 'missing.command';
} }
this.command = command; this.command = command;
this.properties = properties; this.properties = properties;
this.message = message; this.message = message;
} }
toString() { toString() {
let cmdStr = CMD_PREFIX + this.command; let cmdStr = CMD_PREFIX + this.command;
if (this.properties && Object.keys(this.properties).length > 0) { if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' '; cmdStr += ' ';
for (const key in this.properties) { for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) { if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key]; const val = this.properties[key];
if (val) { if (val) {
// safely append the val - avoid blowing up when attempting to // safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
cmdStr += `${key}=${escape(`${val || ''}`)};`; cmdStr += `${key}=${escape(`${val || ''}`)};`;
} }
} }
} }
} }
cmdStr += ']'; cmdStr += ']';
// safely append the message - avoid blowing up when attempting to // safely append the message - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
const message = `${this.message || ''}`; const message = `${this.message || ''}`;
cmdStr += escapeData(message); cmdStr += escapeData(message);
return cmdStr; return cmdStr;
} }
} }
function escapeData(s) { function escapeData(s) {
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A'); return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
} }
function escape(s) { function escape(s) {
return s return s
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A') .replace(/\n/g, '%0A')
.replace(/]/g, '%5D') .replace(/]/g, '%5D')
.replace(/;/g, '%3B'); .replace(/;/g, '%3B');
} }
//# sourceMappingURL=command.js.map //# sourceMappingURL=command.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,OAAe;IACjD,YAAY,CAAC,IAAI,EAAE,EAAE,EA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IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,GAAG,CAAA;QAEb,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}

View File

@@ -1,73 +1,94 @@
/** /**
* Interface for getInput options * Interface for getInput options
*/ */
export interface InputOptions { export interface InputOptions {
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */ /** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
required?: boolean; required?: boolean;
} }
/** /**
* The code to exit an action * The code to exit an action
*/ */
export declare enum ExitCode { export declare enum ExitCode {
/** /**
* A code indicating that the action was successful * A code indicating that the action was successful
*/ */
Success = 0, Success = 0,
/** /**
* A code indicating that the action was a failure * A code indicating that the action was a failure
*/ */
Failure = 1 Failure = 1
} }
/** /**
* sets env variable for this action and future actions in the job * sets env variable for this action and future actions in the job
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val the value of the variable * @param val the value of the variable
*/ */
export declare function exportVariable(name: string, val: string): void; export declare function exportVariable(name: string, val: string): void;
/** /**
* exports the variable and registers a secret which will get masked from logs * exports the variable and registers a secret which will get masked from logs
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val value of the secret * @param val value of the secret
*/ */
export declare function exportSecret(name: string, val: string): void; export declare function exportSecret(name: string, val: string): void;
/** /**
* Prepends inputPath to the PATH (for this action and future actions) * Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath * @param inputPath
*/ */
export declare function addPath(inputPath: string): void; export declare function addPath(inputPath: string): void;
/** /**
* Gets the value of an input. The value is also trimmed. * Gets the value of an input. The value is also trimmed.
* *
* @param name name of the input to get * @param name name of the input to get
* @param options optional. See InputOptions. * @param options optional. See InputOptions.
* @returns string * @returns string
*/ */
export declare function getInput(name: string, options?: InputOptions): string; export declare function getInput(name: string, options?: InputOptions): string;
/** /**
* Sets the value of an output. * Sets the value of an output.
* *
* @param name name of the output to set * @param name name of the output to set
* @param value value to store * @param value value to store
*/ */
export declare function setOutput(name: string, value: string): void; export declare function setOutput(name: string, value: string): void;
/** /**
* Sets the action status to failed. * Sets the action status to failed.
* When the action exits it will be with an exit code of 1 * When the action exits it will be with an exit code of 1
* @param message add error issue message * @param message add error issue message
*/ */
export declare function setFailed(message: string): void; export declare function setFailed(message: string): void;
/** /**
* Writes debug message to user log * Writes debug message to user log
* @param message debug message * @param message debug message
*/ */
export declare function debug(message: string): void; export declare function debug(message: string): void;
/** /**
* Adds an error issue * Adds an error issue
* @param message error issue message * @param message error issue message
*/ */
export declare function error(message: string): void; export declare function error(message: string): void;
/** /**
* Adds an warning issue * Adds an warning issue
* @param message warning issue message * @param message warning issue message
*/ */
export declare function warning(message: string): void; export declare function warning(message: string): void;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
export declare function startGroup(name: string): void;
/**
* End an output group.
*/
export declare function endGroup(): void;
/**
* Wrap an asynchronous function call in a group.
*
* Returns the same type as the function itself.
*
* @param name The name of the group
* @param fn The function to wrap in the group
*/
export declare function group<T>(name: string, fn: () => Promise<T>): Promise<T>;

View File

@@ -1,116 +1,168 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
const command_1 = require("./command"); function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
const path = require("path"); return new (P || (P = Promise))(function (resolve, reject) {
/** function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
* The code to exit an action function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
*/ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
var ExitCode; step((generator = generator.apply(thisArg, _arguments || [])).next());
(function (ExitCode) { });
/** };
* A code indicating that the action was successful Object.defineProperty(exports, "__esModule", { value: true });
*/ const command_1 = require("./command");
ExitCode[ExitCode["Success"] = 0] = "Success"; const path = require("path");
/** /**
* A code indicating that the action was a failure * The code to exit an action
*/ */
ExitCode[ExitCode["Failure"] = 1] = "Failure"; var ExitCode;
})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); (function (ExitCode) {
//----------------------------------------------------------------------- /**
// Variables * A code indicating that the action was successful
//----------------------------------------------------------------------- */
/** ExitCode[ExitCode["Success"] = 0] = "Success";
* sets env variable for this action and future actions in the job /**
* @param name the name of the variable to set * A code indicating that the action was a failure
* @param val the value of the variable */
*/ ExitCode[ExitCode["Failure"] = 1] = "Failure";
function exportVariable(name, val) { })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
process.env[name] = val; //-----------------------------------------------------------------------
command_1.issueCommand('set-env', { name }, val); // Variables
} //-----------------------------------------------------------------------
exports.exportVariable = exportVariable; /**
/** * sets env variable for this action and future actions in the job
* exports the variable and registers a secret which will get masked from logs * @param name the name of the variable to set
* @param name the name of the variable to set * @param val the value of the variable
* @param val value of the secret */
*/ function exportVariable(name, val) {
function exportSecret(name, val) { process.env[name] = val;
exportVariable(name, val); command_1.issueCommand('set-env', { name }, val);
command_1.issueCommand('set-secret', {}, val); }
} exports.exportVariable = exportVariable;
exports.exportSecret = exportSecret; /**
/** * exports the variable and registers a secret which will get masked from logs
* Prepends inputPath to the PATH (for this action and future actions) * @param name the name of the variable to set
* @param inputPath * @param val value of the secret
*/ */
function addPath(inputPath) { function exportSecret(name, val) {
command_1.issueCommand('add-path', {}, inputPath); exportVariable(name, val);
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; // the runner will error with not implemented
} // leaving the function but raising the error earlier
exports.addPath = addPath; command_1.issueCommand('set-secret', {}, val);
/** throw new Error('Not implemented.');
* Gets the value of an input. The value is also trimmed. }
* exports.exportSecret = exportSecret;
* @param name name of the input to get /**
* @param options optional. See InputOptions. * Prepends inputPath to the PATH (for this action and future actions)
* @returns string * @param inputPath
*/ */
function getInput(name, options) { function addPath(inputPath) {
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || ''; command_1.issueCommand('add-path', {}, inputPath);
if (options && options.required && !val) { process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
throw new Error(`Input required and not supplied: ${name}`); }
} exports.addPath = addPath;
return val.trim(); /**
} * Gets the value of an input. The value is also trimmed.
exports.getInput = getInput; *
/** * @param name name of the input to get
* Sets the value of an output. * @param options optional. See InputOptions.
* * @returns string
* @param name name of the output to set */
* @param value value to store function getInput(name, options) {
*/ const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '';
function setOutput(name, value) { if (options && options.required && !val) {
command_1.issueCommand('set-output', { name }, value); throw new Error(`Input required and not supplied: ${name}`);
} }
exports.setOutput = setOutput; return val.trim();
//----------------------------------------------------------------------- }
// Results exports.getInput = getInput;
//----------------------------------------------------------------------- /**
/** * Sets the value of an output.
* Sets the action status to failed. *
* When the action exits it will be with an exit code of 1 * @param name name of the output to set
* @param message add error issue message * @param value value to store
*/ */
function setFailed(message) { function setOutput(name, value) {
process.exitCode = ExitCode.Failure; command_1.issueCommand('set-output', { name }, value);
error(message); }
} exports.setOutput = setOutput;
exports.setFailed = setFailed; //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // Results
// Logging Commands //-----------------------------------------------------------------------
//----------------------------------------------------------------------- /**
/** * Sets the action status to failed.
* Writes debug message to user log * When the action exits it will be with an exit code of 1
* @param message debug message * @param message add error issue message
*/ */
function debug(message) { function setFailed(message) {
command_1.issueCommand('debug', {}, message); process.exitCode = ExitCode.Failure;
} error(message);
exports.debug = debug; }
/** exports.setFailed = setFailed;
* Adds an error issue //-----------------------------------------------------------------------
* @param message error issue message // Logging Commands
*/ //-----------------------------------------------------------------------
function error(message) { /**
command_1.issue('error', message); * Writes debug message to user log
} * @param message debug message
exports.error = error; */
/** function debug(message) {
* Adds an warning issue command_1.issueCommand('debug', {}, message);
* @param message warning issue message }
*/ exports.debug = debug;
function warning(message) { /**
command_1.issue('warning', message); * Adds an error issue
} * @param message error issue message
exports.warning = warning; */
function error(message) {
command_1.issue('error', message);
}
exports.error = error;
/**
* Adds an warning issue
* @param message warning issue message
*/
function warning(message) {
command_1.issue('warning', message);
}
exports.warning = warning;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
function startGroup(name) {
command_1.issue('group', name);
}
exports.startGroup = startGroup;
/**
* End an output group.
*/
function endGroup() {
command_1.issue('endgroup');
}
exports.endGroup = endGroup;
/**
* Wrap an asynchronous function call in a group.
*
* Returns the same type as the function itself.
*
* @param name The name of the group
* @param fn The function to wrap in the group
*/
function group(name, fn) {
return __awaiter(this, void 0, void 0, function* () {
startGroup(name);
let result;
try {
result = yield fn();
}
finally {
endGroup();
}
return result;
});
}
exports.group = group;
//# sourceMappingURL=core.js.map //# sourceMappingURL=core.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;AAAA,uCAA6C;AAE7C,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACzB,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC;AAHD,oCAGC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,O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AA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}

View File

@@ -1,10 +1,11 @@
{ {
"name": "@actions/core", "name": "@actions/core",
"version": "1.0.0", "version": "1.1.0",
"description": "Actions core lib", "description": "Actions core lib",
"keywords": [ "keywords": [
"core", "github",
"actions" "actions",
"core"
], ],
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core", "homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
"license": "MIT", "license": "MIT",
@@ -33,5 +34,5 @@
"devDependencies": { "devDependencies": {
"@types/node": "^12.0.2" "@types/node": "^12.0.2"
}, },
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55" "gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52"
} }

View File

@@ -1,7 +1,7 @@
Copyright 2019 GitHub Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,48 +1,50 @@
# `@actions/github` # `@actions/github`
> A hydrated Octokit client. > A hydrated Octokit client.
## Usage ## Usage
Returns an [Octokit SDK] client. See https://octokit.github.io/rest.js for the API. Returns an Octokit client. See https://octokit.github.io/rest.js for the API.
``` ```js
const github = require('@actions/github'); const github = require('@actions/github');
const core = require('@actions/core'); const core = require('@actions/core');
// This should be a token with access to your repository scoped in as a secret. // This should be a token with access to your repository scoped in as a secret.
const myToken = core.getInput('myToken'); const myToken = core.getInput('myToken');
const octokit = new github.GitHub(myToken); const octokit = new github.GitHub(myToken);
const pulls = await octokit.pulls.get({ const { data: pullRequest } = await octokit.pulls.get({
owner: 'octokit', owner: 'octokit',
repo: 'rest.js', repo: 'rest.js',
pull_number: 123, pull_number: 123,
mediaType: { mediaType: {
format: 'diff' format: 'diff'
} }
}); });
console.log(pulls); console.log(pullRequest);
``` ```
You can also make GraphQL requests: You can pass client options (except `auth`, which is handled by the token argument), as specified by [Octokit](https://octokit.github.io/rest.js/), as a second argument to the `GitHub` constructor.
``` You can also make GraphQL requests. See https://github.com/octokit/graphql.js for the API.
const result = await octokit.graphql(query, variables);
``` ```js
const result = await octokit.graphql(query, variables);
Finally, you can get the context of the current action: ```
``` Finally, you can get the context of the current action:
const github = require('@actions/github');
```js
const context = github.context; const github = require('@actions/github');
const newIssue = await octokit.issues.create({ const context = github.context;
...context.repo,
title: 'New issue!', const newIssue = await octokit.issues.create({
body: 'Hello Universe!' ...context.repo,
}); title: 'New issue!',
``` body: 'Hello Universe!'
});
```

View File

@@ -1,26 +1,26 @@
import { WebhookPayload } from './interfaces'; import { WebhookPayload } from './interfaces';
export declare class Context { export declare class Context {
/** /**
* Webhook payload object that triggered the workflow * Webhook payload object that triggered the workflow
*/ */
payload: WebhookPayload; payload: WebhookPayload;
eventName: string; eventName: string;
sha: string; sha: string;
ref: string; ref: string;
workflow: string; workflow: string;
action: string; action: string;
actor: string; actor: string;
/** /**
* Hydrate the context from the environment * Hydrate the context from the environment
*/ */
constructor(); constructor();
readonly issue: { readonly issue: {
owner: string; owner: string;
repo: string; repo: string;
number: number; number: number;
}; };
readonly repo: { readonly repo: {
owner: string; owner: string;
repo: string; repo: string;
}; };
} }

View File

@@ -1,38 +1,45 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/no-require-imports */ const fs_1 = require("fs");
class Context { const os_1 = require("os");
/** class Context {
* Hydrate the context from the environment /**
*/ * Hydrate the context from the environment
constructor() { */
this.payload = process.env.GITHUB_EVENT_PATH constructor() {
? require(process.env.GITHUB_EVENT_PATH) this.payload = {};
: {}; if (process.env.GITHUB_EVENT_PATH) {
this.eventName = process.env.GITHUB_EVENT_NAME; if (fs_1.existsSync(process.env.GITHUB_EVENT_PATH)) {
this.sha = process.env.GITHUB_SHA; this.payload = JSON.parse(fs_1.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' }));
this.ref = process.env.GITHUB_REF; }
this.workflow = process.env.GITHUB_WORKFLOW; else {
this.action = process.env.GITHUB_ACTION; process.stdout.write(`GITHUB_EVENT_PATH ${process.env.GITHUB_EVENT_PATH} does not exist${os_1.EOL}`);
this.actor = process.env.GITHUB_ACTOR; }
} }
get issue() { this.eventName = process.env.GITHUB_EVENT_NAME;
const payload = this.payload; this.sha = process.env.GITHUB_SHA;
return Object.assign({}, this.repo, { number: (payload.issue || payload.pullRequest || payload).number }); this.ref = process.env.GITHUB_REF;
} this.workflow = process.env.GITHUB_WORKFLOW;
get repo() { this.action = process.env.GITHUB_ACTION;
if (process.env.GITHUB_REPOSITORY) { this.actor = process.env.GITHUB_ACTOR;
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); }
return { owner, repo }; get issue() {
} const payload = this.payload;
if (this.payload.repository) { return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pullRequest || payload).number });
return { }
owner: this.payload.repository.owner.login, get repo() {
repo: this.payload.repository.name if (process.env.GITHUB_REPOSITORY) {
}; const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
} return { owner, repo };
throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'"); }
} if (this.payload.repository) {
} return {
exports.Context = Context; 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 //# sourceMappingURL=context.js.map

View File

@@ -1 +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,GAAG,CAAC,iBAAiB;YAC1C,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;YACxC,CAAC,CAAC,EAAE,CAAA;QACN,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,iBAA2B,CAAA;QACxD,IAAI,CAAC,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D,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,CAAA;SACrB;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YAC3B,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK;gBAC1C,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI;aACnC,CAAA;SACF;QAED,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAA;IACH,CAAC;CACF;AAjED,0BAiEC"}

View File

@@ -1,8 +1,8 @@
import { GraphQlQueryResponse, Variables } from '@octokit/graphql'; import { GraphQlQueryResponse, Variables } from '@octokit/graphql';
import Octokit from '@octokit/rest'; import Octokit from '@octokit/rest';
import * as Context from './context'; import * as Context from './context';
export declare const context: Context.Context; export declare const context: Context.Context;
export declare class GitHub extends Octokit { export declare class GitHub extends Octokit {
graphql: (query: string, variables?: Variables) => Promise<GraphQlQueryResponse>; graphql: (query: string, variables?: Variables) => Promise<GraphQlQueryResponse>;
constructor(token: string); constructor(token: string, opts?: Omit<Octokit.Options, 'auth'>);
} }

View File

@@ -1,29 +1,29 @@
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod; result["default"] = mod;
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts // Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
const graphql_1 = require("@octokit/graphql"); const graphql_1 = require("@octokit/graphql");
const rest_1 = __importDefault(require("@octokit/rest")); const rest_1 = __importDefault(require("@octokit/rest"));
const Context = __importStar(require("./context")); const Context = __importStar(require("./context"));
// We need this in order to extend Octokit // We need this in order to extend Octokit
rest_1.default.prototype = new rest_1.default(); rest_1.default.prototype = new rest_1.default();
exports.context = new Context.Context(); exports.context = new Context.Context();
class GitHub extends rest_1.default { class GitHub extends rest_1.default {
constructor(token) { constructor(token, opts = {}) {
super({ auth: `token ${token}` }); super(Object.assign(Object.assign({}, opts), { auth: `token ${token}` }));
this.graphql = graphql_1.defaults({ this.graphql = graphql_1.defaults({
headers: { authorization: `token ${token}` } headers: { authorization: `token ${token}` }
}); });
} }
} }
exports.GitHub = GitHub; exports.GitHub = GitHub;
//# sourceMappingURL=github.js.map //# sourceMappingURL=github.js.map

View File

@@ -1 +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"} {"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,EAAE,OAAsC,EAAE;QACjE,KAAK,iCAAK,IAAI,KAAE,IAAI,EAAE,SAAS,KAAK,EAAE,IAAE,CAAA;QACxC,IAAI,CAAC,OAAO,GAAG,kBAAQ,CAAC;YACtB,OAAO,EAAE,EAAC,aAAa,EAAE,SAAS,KAAK,EAAE,EAAC;SAC3C,CAAC,CAAA;IACJ,CAAC;CACF;AAZD,wBAYC"}

View File

@@ -1,36 +1,36 @@
export interface PayloadRepository { export interface PayloadRepository {
[key: string]: any; [key: string]: any;
full_name?: string; full_name?: string;
name: string; name: string;
owner: { owner: {
[key: string]: any; [key: string]: any;
login: string; login: string;
name?: string; name?: string;
}; };
html_url?: string; html_url?: string;
} }
export interface WebhookPayload { export interface WebhookPayload {
[key: string]: any; [key: string]: any;
repository?: PayloadRepository; repository?: PayloadRepository;
issue?: { issue?: {
[key: string]: any; [key: string]: any;
number: number; number: number;
html_url?: string; html_url?: string;
body?: string; body?: string;
}; };
pull_request?: { pull_request?: {
[key: string]: any; [key: string]: any;
number: number; number: number;
html_url?: string; html_url?: string;
body?: string; body?: string;
}; };
sender?: { sender?: {
[key: string]: any; [key: string]: any;
type: string; type: string;
}; };
action?: string; action?: string;
installation?: { installation?: {
id: number; id: number;
[key: string]: any; [key: string]: any;
}; };
} }

View File

@@ -1,4 +1,4 @@
"use strict"; "use strict";
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map //# sourceMappingURL=interfaces.js.map

View File

@@ -1,6 +1,6 @@
{ {
"name": "@actions/github", "name": "@actions/github",
"version": "1.0.0", "version": "1.1.0",
"description": "Actions github lib", "description": "Actions github lib",
"keywords": [ "keywords": [
"github", "github",
@@ -38,5 +38,5 @@
"devDependencies": { "devDependencies": {
"jest": "^24.7.1" "jest": "^24.7.1"
}, },
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55" "gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52"
} }

View File

@@ -2,7 +2,7 @@
"private": true, "private": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.0.0", "@actions/core": "^1.1.0",
"@actions/github": "^1.0.0" "@actions/github": "^1.1.0"
} }
} }

View File

@@ -2,15 +2,15 @@
# yarn lockfile v1 # yarn lockfile v1
"@actions/core@^1.0.0": "@actions/core@^1.1.0":
version "1.0.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.0.0.tgz#4a090a2e958cc300b9ea802331034d5faf42d239" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.1.0.tgz#25c3aff43a20f9c5a04e2a3439898a49ba8d3625"
integrity sha512-aMIlkx96XH4E/2YZtEOeyrYQfhlas9jIRkfGPqMwXD095Rdkzo4lB6ZmbxPQSzD+e1M+Xsm98ZhuSMYGv/AlqA== integrity sha512-KKpo3xzo0Zsikni9tbOsEQkxZBGDsYSJZNkTvmo0gPSXrc98TBOcdTvKwwjitjkjHkreTggWdB1ACiAFVgsuzA==
"@actions/github@^1.0.0": "@actions/github@^1.1.0":
version "1.0.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/@actions/github/-/github-1.0.0.tgz#5154cadd93c4b17217f56304ee27056730b8ae88" resolved "https://registry.yarnpkg.com/@actions/github/-/github-1.1.0.tgz#06f34e6b0cf07eb2b3641de3e680dbfae6bcd400"
integrity sha512-PPbWZ5wFAD/Vr+RCECfR3KNHjTwYln4liJBihs9tQUL0/PCFqB2lSkIh9V94AcZFHxgKk8snImjuLaBE8bKR7A== integrity sha512-cHf6PyoNMdei13jEdGPhKprIMFmjVVW/dnM5/9QmQDJ1ZTaGVyezUSCUIC/ySNLRvDUpeFwPYMdThSEJldSbUw==
dependencies: dependencies:
"@octokit/graphql" "^2.0.1" "@octokit/graphql" "^2.0.1"
"@octokit/rest" "^16.15.0" "@octokit/rest" "^16.15.0"