Skip to content

Commit a4e2ada

Browse files
authored
fix(action): skip github comment if PR not found (#656)
Co-authored-by: danadajian <[email protected]>
1 parent c9c5b3e commit a4e2ada

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

action/dist/main.js

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17600,12 +17600,12 @@ var require_lib = __commonJS({
1760017600
throw new Error("Client has already been disposed.");
1760117601
}
1760217602
const parsedUrl = new URL(requestUrl);
17603-
let info3 = this._prepareRequest(verb, parsedUrl, headers);
17603+
let info4 = this._prepareRequest(verb, parsedUrl, headers);
1760417604
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) ? this._maxRetries + 1 : 1;
1760517605
let numTries = 0;
1760617606
let response;
1760717607
do {
17608-
response = yield this.requestRaw(info3, data);
17608+
response = yield this.requestRaw(info4, data);
1760917609
if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
1761017610
let authenticationHandler;
1761117611
for (const handler2 of this.handlers) {
@@ -17615,7 +17615,7 @@ var require_lib = __commonJS({
1761517615
}
1761617616
}
1761717617
if (authenticationHandler) {
17618-
return authenticationHandler.handleAuthentication(this, info3, data);
17618+
return authenticationHandler.handleAuthentication(this, info4, data);
1761917619
} else {
1762017620
return response;
1762117621
}
@@ -17638,8 +17638,8 @@ var require_lib = __commonJS({
1763817638
}
1763917639
}
1764017640
}
17641-
info3 = this._prepareRequest(verb, parsedRedirectUrl, headers);
17642-
response = yield this.requestRaw(info3, data);
17641+
info4 = this._prepareRequest(verb, parsedRedirectUrl, headers);
17642+
response = yield this.requestRaw(info4, data);
1764317643
redirectsRemaining--;
1764417644
}
1764517645
if (!response.message.statusCode || !HttpResponseRetryCodes.includes(response.message.statusCode)) {
@@ -17668,7 +17668,7 @@ var require_lib = __commonJS({
1766817668
* @param info
1766917669
* @param data
1767017670
*/
17671-
requestRaw(info3, data) {
17671+
requestRaw(info4, data) {
1767217672
return __awaiter(this, void 0, void 0, function* () {
1767317673
return new Promise((resolve, reject) => {
1767417674
function callbackForResult(err, res) {
@@ -17680,7 +17680,7 @@ var require_lib = __commonJS({
1768017680
resolve(res);
1768117681
}
1768217682
}
17683-
this.requestRawWithCallback(info3, data, callbackForResult);
17683+
this.requestRawWithCallback(info4, data, callbackForResult);
1768417684
});
1768517685
});
1768617686
}
@@ -17690,12 +17690,12 @@ var require_lib = __commonJS({
1769017690
* @param data
1769117691
* @param onResult
1769217692
*/
17693-
requestRawWithCallback(info3, data, onResult) {
17693+
requestRawWithCallback(info4, data, onResult) {
1769417694
if (typeof data === "string") {
17695-
if (!info3.options.headers) {
17696-
info3.options.headers = {};
17695+
if (!info4.options.headers) {
17696+
info4.options.headers = {};
1769717697
}
17698-
info3.options.headers["Content-Length"] = Buffer.byteLength(data, "utf8");
17698+
info4.options.headers["Content-Length"] = Buffer.byteLength(data, "utf8");
1769917699
}
1770017700
let callbackCalled = false;
1770117701
function handleResult(err, res) {
@@ -17704,7 +17704,7 @@ var require_lib = __commonJS({
1770417704
onResult(err, res);
1770517705
}
1770617706
}
17707-
const req = info3.httpModule.request(info3.options, (msg) => {
17707+
const req = info4.httpModule.request(info4.options, (msg) => {
1770817708
const res = new HttpClientResponse(msg);
1770917709
handleResult(void 0, res);
1771017710
});
@@ -17716,7 +17716,7 @@ var require_lib = __commonJS({
1771617716
if (socket) {
1771717717
socket.end();
1771817718
}
17719-
handleResult(new Error(`Request timeout: ${info3.options.path}`));
17719+
handleResult(new Error(`Request timeout: ${info4.options.path}`));
1772017720
});
1772117721
req.on("error", function(err) {
1772217722
handleResult(err);
@@ -17752,27 +17752,27 @@ var require_lib = __commonJS({
1775217752
return this._getProxyAgentDispatcher(parsedUrl, proxyUrl);
1775317753
}
1775417754
_prepareRequest(method, requestUrl, headers) {
17755-
const info3 = {};
17756-
info3.parsedUrl = requestUrl;
17757-
const usingSsl = info3.parsedUrl.protocol === "https:";
17758-
info3.httpModule = usingSsl ? https : http;
17755+
const info4 = {};
17756+
info4.parsedUrl = requestUrl;
17757+
const usingSsl = info4.parsedUrl.protocol === "https:";
17758+
info4.httpModule = usingSsl ? https : http;
1775917759
const defaultPort = usingSsl ? 443 : 80;
17760-
info3.options = {};
17761-
info3.options.host = info3.parsedUrl.hostname;
17762-
info3.options.port = info3.parsedUrl.port ? parseInt(info3.parsedUrl.port) : defaultPort;
17763-
info3.options.path = (info3.parsedUrl.pathname || "") + (info3.parsedUrl.search || "");
17764-
info3.options.method = method;
17765-
info3.options.headers = this._mergeHeaders(headers);
17760+
info4.options = {};
17761+
info4.options.host = info4.parsedUrl.hostname;
17762+
info4.options.port = info4.parsedUrl.port ? parseInt(info4.parsedUrl.port) : defaultPort;
17763+
info4.options.path = (info4.parsedUrl.pathname || "") + (info4.parsedUrl.search || "");
17764+
info4.options.method = method;
17765+
info4.options.headers = this._mergeHeaders(headers);
1776617766
if (this.userAgent != null) {
17767-
info3.options.headers["user-agent"] = this.userAgent;
17767+
info4.options.headers["user-agent"] = this.userAgent;
1776817768
}
17769-
info3.options.agent = this._getAgent(info3.parsedUrl);
17769+
info4.options.agent = this._getAgent(info4.parsedUrl);
1777017770
if (this.handlers) {
1777117771
for (const handler2 of this.handlers) {
17772-
handler2.prepareRequest(info3.options);
17772+
handler2.prepareRequest(info4.options);
1777317773
}
1777417774
}
17775-
return info3;
17775+
return info4;
1777617776
}
1777717777
_mergeHeaders(headers) {
1777817778
if (this.requestOptions && this.requestOptions.headers) {
@@ -19762,10 +19762,10 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
1976219762
(0, command_1.issueCommand)("notice", (0, utils_1.toCommandProperties)(properties), message instanceof Error ? message.toString() : message);
1976319763
}
1976419764
exports2.notice = notice;
19765-
function info3(message) {
19765+
function info4(message) {
1976619766
process.stdout.write(message + os.EOL);
1976719767
}
19768-
exports2.info = info3;
19768+
exports2.info = info4;
1976919769
function startGroup(name) {
1977019770
(0, command_1.issue)("group", name);
1977119771
}
@@ -21708,9 +21708,9 @@ var require_debuggability = __commonJS({
2170821708
}
2170921709
shouldIgnore = function(line) {
2171021710
if (bluebirdFramePattern.test(line)) return true;
21711-
var info3 = parseLineInfo(line);
21712-
if (info3) {
21713-
if (info3.fileName === firstFileName && (firstIndex <= info3.line && info3.line <= lastIndex)) {
21711+
var info4 = parseLineInfo(line);
21712+
if (info4) {
21713+
if (info4.fileName === firstFileName && (firstIndex <= info4.line && info4.line <= lastIndex)) {
2171421714
return true;
2171521715
}
2171621716
}
@@ -36656,6 +36656,10 @@ ${comparadiseCommentDetails}` : comparadiseBaseComment;
3665636656
...import_github3.context.repo
3665736657
});
3665836658
const prNumber = data.find(Boolean)?.number ?? import_github3.context.issue.number;
36659+
if (!prNumber) {
36660+
(0, import_core4.info)("No PR number found, skipping comment creation.");
36661+
return;
36662+
}
3665936663
const { data: comments } = await octokit.rest.issues.listComments({
3666036664
issue_number: prNumber,
3666136665
...import_github3.context.repo

action/dist/main.js.map

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

action/src/comment.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { octokit } from './octokit';
22
import { context } from '@actions/github';
3-
import { getInput } from '@actions/core';
3+
import { getInput, info } from '@actions/core';
44
import { buildComparadiseUrl } from './build-comparadise-url';
55

66
export const createGithubComment = async () => {
@@ -22,6 +22,10 @@ export const createGithubComment = async () => {
2222
...context.repo
2323
});
2424
const prNumber = data.find(Boolean)?.number ?? context.issue.number;
25+
if (!prNumber) {
26+
info('No PR number found, skipping comment creation.');
27+
return;
28+
}
2529

2630
const { data: comments } = await octokit.rest.issues.listComments({
2731
issue_number: prNumber,

0 commit comments

Comments
 (0)