Skip to content

Commit 2fc55e8

Browse files
committed
1.4.0
1 parent fce2295 commit 2fc55e8

File tree

3 files changed

+153
-32
lines changed

3 files changed

+153
-32
lines changed

dist/index.js

Lines changed: 151 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,32 @@ const windowsRelease = release => {
19991999
module.exports = windowsRelease;
20002000

20012001

2002+
/***/ }),
2003+
2004+
/***/ 82:
2005+
/***/ (function(__unusedmodule, exports) {
2006+
2007+
"use strict";
2008+
2009+
// We use any as a valid input type
2010+
/* eslint-disable @typescript-eslint/no-explicit-any */
2011+
Object.defineProperty(exports, "__esModule", { value: true });
2012+
/**
2013+
* Sanitizes an input into a string so it can be passed into issueCommand safely
2014+
* @param input input to sanitize into a string
2015+
*/
2016+
function toCommandValue(input) {
2017+
if (input === null || input === undefined) {
2018+
return '';
2019+
}
2020+
else if (typeof input === 'string' || input instanceof String) {
2021+
return input;
2022+
}
2023+
return JSON.stringify(input);
2024+
}
2025+
exports.toCommandValue = toCommandValue;
2026+
//# sourceMappingURL=utils.js.map
2027+
20022028
/***/ }),
20032029

20042030
/***/ 87:
@@ -2008,6 +2034,42 @@ module.exports = require("os");
20082034

20092035
/***/ }),
20102036

2037+
/***/ 102:
2038+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
2039+
2040+
"use strict";
2041+
2042+
// For internal use, subject to change.
2043+
var __importStar = (this && this.__importStar) || function (mod) {
2044+
if (mod && mod.__esModule) return mod;
2045+
var result = {};
2046+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
2047+
result["default"] = mod;
2048+
return result;
2049+
};
2050+
Object.defineProperty(exports, "__esModule", { value: true });
2051+
// We use any as a valid input type
2052+
/* eslint-disable @typescript-eslint/no-explicit-any */
2053+
const fs = __importStar(__webpack_require__(747));
2054+
const os = __importStar(__webpack_require__(87));
2055+
const utils_1 = __webpack_require__(82);
2056+
function issueCommand(command, message) {
2057+
const filePath = process.env[`GITHUB_${command}`];
2058+
if (!filePath) {
2059+
throw new Error(`Unable to find environment variable for file command ${command}`);
2060+
}
2061+
if (!fs.existsSync(filePath)) {
2062+
throw new Error(`Missing file at path: ${filePath}`);
2063+
}
2064+
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
2065+
encoding: 'utf8'
2066+
});
2067+
}
2068+
exports.issueCommand = issueCommand;
2069+
//# sourceMappingURL=file-command.js.map
2070+
2071+
/***/ }),
2072+
20112073
/***/ 104:
20122074
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
20132075

@@ -2021,6 +2083,7 @@ const main = async () => {
20212083
const token = core.getInput('github-token')
20222084
const branch = core.getInput('branch')
20232085
const base = core.getInput('base')
2086+
const author = core.getInput('author')
20242087

20252088
const query = {
20262089
...context.repo,
@@ -2037,7 +2100,9 @@ const main = async () => {
20372100
const octokit = new GitHub(token)
20382101

20392102
const res = await octokit.pulls.list(query)
2040-
const pr = res.data.length && res.data[0]
2103+
const pr = author
2104+
? res.data.length && res.data.filter(pr => pr.user.login === author)[0]
2105+
: res.data.length && res.data[0]
20412106

20422107
core.debug(`pr: ${JSON.stringify(pr, null, 2)}`)
20432108
core.setOutput('number', pr ? pr.number : '')
@@ -4734,17 +4799,25 @@ function octokitValidate(octokit) {
47344799

47354800
"use strict";
47364801

4802+
var __importStar = (this && this.__importStar) || function (mod) {
4803+
if (mod && mod.__esModule) return mod;
4804+
var result = {};
4805+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
4806+
result["default"] = mod;
4807+
return result;
4808+
};
47374809
Object.defineProperty(exports, "__esModule", { value: true });
4738-
const os = __webpack_require__(87);
4810+
const os = __importStar(__webpack_require__(87));
4811+
const utils_1 = __webpack_require__(82);
47394812
/**
47404813
* Commands
47414814
*
47424815
* Command Format:
4743-
* ##[name key=value;key=value]message
4816+
* ::name key=value,key=value::message
47444817
*
47454818
* Examples:
4746-
* ##[warning]This is the user warning message
4747-
* ##[set-secret name=mypassword]definitelyNotAPassword!
4819+
* ::warning::This is the message
4820+
* ::set-env name=MY_VAR::some value
47484821
*/
47494822
function issueCommand(command, properties, message) {
47504823
const cmd = new Command(command, properties, message);
@@ -4769,34 +4842,39 @@ class Command {
47694842
let cmdStr = CMD_STRING + this.command;
47704843
if (this.properties && Object.keys(this.properties).length > 0) {
47714844
cmdStr += ' ';
4845+
let first = true;
47724846
for (const key in this.properties) {
47734847
if (this.properties.hasOwnProperty(key)) {
47744848
const val = this.properties[key];
47754849
if (val) {
4776-
// safely append the val - avoid blowing up when attempting to
4777-
// call .replace() if message is not a string for some reason
4778-
cmdStr += `${key}=${escape(`${val || ''}`)},`;
4850+
if (first) {
4851+
first = false;
4852+
}
4853+
else {
4854+
cmdStr += ',';
4855+
}
4856+
cmdStr += `${key}=${escapeProperty(val)}`;
47794857
}
47804858
}
47814859
}
47824860
}
4783-
cmdStr += CMD_STRING;
4784-
// safely append the message - avoid blowing up when attempting to
4785-
// call .replace() if message is not a string for some reason
4786-
const message = `${this.message || ''}`;
4787-
cmdStr += escapeData(message);
4861+
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
47884862
return cmdStr;
47894863
}
47904864
}
47914865
function escapeData(s) {
4792-
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
4866+
return utils_1.toCommandValue(s)
4867+
.replace(/%/g, '%25')
4868+
.replace(/\r/g, '%0D')
4869+
.replace(/\n/g, '%0A');
47934870
}
4794-
function escape(s) {
4795-
return s
4871+
function escapeProperty(s) {
4872+
return utils_1.toCommandValue(s)
4873+
.replace(/%/g, '%25')
47964874
.replace(/\r/g, '%0D')
47974875
.replace(/\n/g, '%0A')
4798-
.replace(/]/g, '%5D')
4799-
.replace(/;/g, '%3B');
4876+
.replace(/:/g, '%3A')
4877+
.replace(/,/g, '%2C');
48004878
}
48014879
//# sourceMappingURL=command.js.map
48024880

@@ -6714,10 +6792,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
67146792
step((generator = generator.apply(thisArg, _arguments || [])).next());
67156793
});
67166794
};
6795+
var __importStar = (this && this.__importStar) || function (mod) {
6796+
if (mod && mod.__esModule) return mod;
6797+
var result = {};
6798+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6799+
result["default"] = mod;
6800+
return result;
6801+
};
67176802
Object.defineProperty(exports, "__esModule", { value: true });
67186803
const command_1 = __webpack_require__(431);
6719-
const os = __webpack_require__(87);
6720-
const path = __webpack_require__(622);
6804+
const file_command_1 = __webpack_require__(102);
6805+
const utils_1 = __webpack_require__(82);
6806+
const os = __importStar(__webpack_require__(87));
6807+
const path = __importStar(__webpack_require__(622));
67216808
/**
67226809
* The code to exit an action
67236810
*/
@@ -6738,11 +6825,21 @@ var ExitCode;
67386825
/**
67396826
* Sets env variable for this action and future actions in the job
67406827
* @param name the name of the variable to set
6741-
* @param val the value of the variable
6828+
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
67426829
*/
6830+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
67436831
function exportVariable(name, val) {
6744-
process.env[name] = val;
6745-
command_1.issueCommand('set-env', { name }, val);
6832+
const convertedVal = utils_1.toCommandValue(val);
6833+
process.env[name] = convertedVal;
6834+
const filePath = process.env['GITHUB_ENV'] || '';
6835+
if (filePath) {
6836+
const delimiter = '_GitHubActionsFileCommandDelimeter_';
6837+
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
6838+
file_command_1.issueCommand('ENV', commandValue);
6839+
}
6840+
else {
6841+
command_1.issueCommand('set-env', { name }, convertedVal);
6842+
}
67466843
}
67476844
exports.exportVariable = exportVariable;
67486845
/**
@@ -6758,7 +6855,13 @@ exports.setSecret = setSecret;
67586855
* @param inputPath
67596856
*/
67606857
function addPath(inputPath) {
6761-
command_1.issueCommand('add-path', {}, inputPath);
6858+
const filePath = process.env['GITHUB_PATH'] || '';
6859+
if (filePath) {
6860+
file_command_1.issueCommand('PATH', inputPath);
6861+
}
6862+
else {
6863+
command_1.issueCommand('add-path', {}, inputPath);
6864+
}
67626865
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
67636866
}
67646867
exports.addPath = addPath;
@@ -6781,12 +6884,22 @@ exports.getInput = getInput;
67816884
* Sets the value of an output.
67826885
*
67836886
* @param name name of the output to set
6784-
* @param value value to store
6887+
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
67856888
*/
6889+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
67866890
function setOutput(name, value) {
67876891
command_1.issueCommand('set-output', { name }, value);
67886892
}
67896893
exports.setOutput = setOutput;
6894+
/**
6895+
* Enables or disables the echoing of commands into stdout for the rest of the step.
6896+
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
6897+
*
6898+
*/
6899+
function setCommandEcho(enabled) {
6900+
command_1.issue('echo', enabled ? 'on' : 'off');
6901+
}
6902+
exports.setCommandEcho = setCommandEcho;
67906903
//-----------------------------------------------------------------------
67916904
// Results
67926905
//-----------------------------------------------------------------------
@@ -6803,6 +6916,13 @@ exports.setFailed = setFailed;
68036916
//-----------------------------------------------------------------------
68046917
// Logging Commands
68056918
//-----------------------------------------------------------------------
6919+
/**
6920+
* Gets whether Actions Step Debug is on or not
6921+
*/
6922+
function isDebug() {
6923+
return process.env['RUNNER_DEBUG'] === '1';
6924+
}
6925+
exports.isDebug = isDebug;
68066926
/**
68076927
* Writes debug message to user log
68086928
* @param message debug message
@@ -6813,18 +6933,18 @@ function debug(message) {
68136933
exports.debug = debug;
68146934
/**
68156935
* Adds an error issue
6816-
* @param message error issue message
6936+
* @param message error issue message. Errors will be converted to string via toString()
68176937
*/
68186938
function error(message) {
6819-
command_1.issue('error', message);
6939+
command_1.issue('error', message instanceof Error ? message.toString() : message);
68206940
}
68216941
exports.error = error;
68226942
/**
68236943
* Adds an warning issue
6824-
* @param message warning issue message
6944+
* @param message warning issue message. Errors will be converted to string via toString()
68256945
*/
68266946
function warning(message) {
6827-
command_1.issue('warning', message);
6947+
command_1.issue('warning', message instanceof Error ? message.toString() : message);
68286948
}
68296949
exports.warning = warning;
68306950
/**
@@ -6882,8 +7002,9 @@ exports.group = group;
68827002
* Saves state for current action, the state can only be retrieved by this action's post job execution.
68837003
*
68847004
* @param name name of the state to store
6885-
* @param value value to store
7005+
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
68867006
*/
7007+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
68877008
function saveState(name, value) {
68887009
command_1.issueCommand('save-state', { name }, value);
68897010
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "find-pull-request-action",
33
"private": true,
4-
"version": "1.3.0",
4+
"version": "1.4.0",
55
"license": "MIT",
66
"description": "GitHub Action for finding pull requests",
77
"repository": "juliangruber/find-pull-request-action",

0 commit comments

Comments
 (0)