Skip to content

Commit c63b71a

Browse files
committed
feat: custom owner/repo, reactions without message, fix deps
Cherry-picked from upstream PRs into the PR Commenter fork: - PR #388: Add owner and repo inputs for cross-repo PR comments - PR #384: Allow adding reactions without providing a message - PR #433: Fix undici CVE-2025-22150 (5.28.4 -> 5.29.0 via npm update) - npm update: @types/node 22.8.6 -> 22.19.21, prettier 3.3.3 -> 3.8.4, @vercel/ncc 0.38.2 -> 0.38.4
1 parent 5c93ec2 commit c63b71a

6 files changed

Lines changed: 330 additions & 493 deletions

File tree

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ inputs:
2424
create-if-not-exists:
2525
description: 'Whether a comment should be created even if comment-tag is not found.'
2626
default: 'true'
27+
owner:
28+
description: 'Repository owner if different than one action is running in'
29+
required: false
30+
repo:
31+
description: 'Repository name if different than one action is running in'
32+
required: false
2733
runs:
2834
using: 'node24'
2935
main: 'lib/index.js'

lib/cleanup/index.js

Lines changed: 89 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,7 @@ class Context {
18821882
this.action = process.env.GITHUB_ACTION;
18831883
this.actor = process.env.GITHUB_ACTOR;
18841884
this.job = process.env.GITHUB_JOB;
1885+
this.runAttempt = parseInt(process.env.GITHUB_RUN_ATTEMPT, 10);
18851886
this.runNumber = parseInt(process.env.GITHUB_RUN_NUMBER, 10);
18861887
this.runId = parseInt(process.env.GITHUB_RUN_ID, 10);
18871888
this.apiUrl = (_a = process.env.GITHUB_API_URL) !== null && _a !== void 0 ? _a : `https://api.github.com`;
@@ -3557,25 +3558,40 @@ var __copyProps = (to, from, except, desc) => {
35573558
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35583559

35593560
// pkg/dist-src/index.js
3560-
var dist_src_exports = {};
3561-
__export(dist_src_exports, {
3561+
var index_exports = {};
3562+
__export(index_exports, {
35623563
Octokit: () => Octokit
35633564
});
3564-
module.exports = __toCommonJS(dist_src_exports);
3565+
module.exports = __toCommonJS(index_exports);
35653566
var import_universal_user_agent = __nccwpck_require__(3843);
35663567
var import_before_after_hook = __nccwpck_require__(2732);
35673568
var import_request = __nccwpck_require__(8636);
35683569
var import_graphql = __nccwpck_require__(7);
35693570
var import_auth_token = __nccwpck_require__(7864);
35703571

35713572
// pkg/dist-src/version.js
3572-
var VERSION = "5.2.0";
3573+
var VERSION = "5.2.2";
35733574

35743575
// pkg/dist-src/index.js
35753576
var noop = () => {
35763577
};
35773578
var consoleWarn = console.warn.bind(console);
35783579
var consoleError = console.error.bind(console);
3580+
function createLogger(logger = {}) {
3581+
if (typeof logger.debug !== "function") {
3582+
logger.debug = noop;
3583+
}
3584+
if (typeof logger.info !== "function") {
3585+
logger.info = noop;
3586+
}
3587+
if (typeof logger.warn !== "function") {
3588+
logger.warn = consoleWarn;
3589+
}
3590+
if (typeof logger.error !== "function") {
3591+
logger.error = consoleError;
3592+
}
3593+
return logger;
3594+
}
35793595
var userAgentTrail = `octokit-core.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`;
35803596
var Octokit = class {
35813597
static {
@@ -3649,15 +3665,7 @@ var Octokit = class {
36493665
}
36503666
this.request = import_request.request.defaults(requestDefaults);
36513667
this.graphql = (0, import_graphql.withCustomRequest)(this.request).defaults(requestDefaults);
3652-
this.log = Object.assign(
3653-
{
3654-
debug: noop,
3655-
info: noop,
3656-
warn: consoleWarn,
3657-
error: consoleError
3658-
},
3659-
options.log
3660-
);
3668+
this.log = createLogger(options.log);
36613669
this.hook = hook;
36623670
if (!options.authStrategy) {
36633671
if (!options.auth) {
@@ -3736,7 +3744,7 @@ module.exports = __toCommonJS(dist_src_exports);
37363744
var import_universal_user_agent = __nccwpck_require__(3843);
37373745

37383746
// pkg/dist-src/version.js
3739-
var VERSION = "9.0.5";
3747+
var VERSION = "9.0.6";
37403748

37413749
// pkg/dist-src/defaults.js
37423750
var userAgent = `octokit-endpoint.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`;
@@ -3841,9 +3849,9 @@ function addQueryParameters(url, parameters) {
38413849
}
38423850

38433851
// pkg/dist-src/util/extract-url-variable-names.js
3844-
var urlVariableRegex = /\{[^}]+\}/g;
3852+
var urlVariableRegex = /\{[^{}}]+\}/g;
38453853
function removeNonChars(variableName) {
3846-
return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
3854+
return variableName.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g, "").split(/,/);
38473855
}
38483856
function extractUrlVariableNames(url) {
38493857
const matches = url.match(urlVariableRegex);
@@ -4029,7 +4037,7 @@ function parse(options) {
40294037
}
40304038
if (url.endsWith("/graphql")) {
40314039
if (options.mediaType.previews?.length) {
4032-
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
4040+
const previewsFromAcceptHeader = headers.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g) || [];
40334041
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {
40344042
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
40354043
return `application/vnd.github.${preview}-preview${format}`;
@@ -4110,18 +4118,18 @@ var __copyProps = (to, from, except, desc) => {
41104118
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41114119

41124120
// pkg/dist-src/index.js
4113-
var dist_src_exports = {};
4114-
__export(dist_src_exports, {
4121+
var index_exports = {};
4122+
__export(index_exports, {
41154123
GraphqlResponseError: () => GraphqlResponseError,
41164124
graphql: () => graphql2,
41174125
withCustomRequest: () => withCustomRequest
41184126
});
4119-
module.exports = __toCommonJS(dist_src_exports);
4127+
module.exports = __toCommonJS(index_exports);
41204128
var import_request3 = __nccwpck_require__(8636);
41214129
var import_universal_user_agent = __nccwpck_require__(3843);
41224130

41234131
// pkg/dist-src/version.js
4124-
var VERSION = "7.1.0";
4132+
var VERSION = "7.1.1";
41254133

41264134
// pkg/dist-src/with-defaults.js
41274135
var import_request2 = __nccwpck_require__(8636);
@@ -4169,8 +4177,7 @@ function graphql(request2, query, options) {
41694177
);
41704178
}
41714179
for (const key in options) {
4172-
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
4173-
continue;
4180+
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) continue;
41744181
return Promise.reject(
41754182
new Error(
41764183
`[@octokit/graphql] "${key}" cannot be used as variable name`
@@ -4278,7 +4285,7 @@ __export(dist_src_exports, {
42784285
module.exports = __toCommonJS(dist_src_exports);
42794286

42804287
// pkg/dist-src/version.js
4281-
var VERSION = "9.2.1";
4288+
var VERSION = "9.2.2";
42824289

42834290
// pkg/dist-src/normalize-paginated-list-response.js
42844291
function normalizePaginatedListResponse(response) {
@@ -4326,7 +4333,7 @@ function iterator(octokit, route, parameters) {
43264333
const response = await requestMethod({ method, url, headers });
43274334
const normalizedResponse = normalizePaginatedListResponse(response);
43284335
url = ((normalizedResponse.headers.link || "").match(
4329-
/<([^>]+)>;\s*rel="next"/
4336+
/<([^<>]+)>;\s*rel="next"/
43304337
) || [])[1];
43314338
return { value: normalizedResponse };
43324339
} catch (error) {
@@ -6878,7 +6885,7 @@ var RequestError = class extends Error {
68786885
if (options.request.headers.authorization) {
68796886
requestCopy.headers = Object.assign({}, options.request.headers, {
68806887
authorization: options.request.headers.authorization.replace(
6881-
/ .*$/,
6888+
/(?<! ) .*$/,
68826889
" [REDACTED]"
68836890
)
68846891
});
@@ -6946,7 +6953,7 @@ var import_endpoint = __nccwpck_require__(4471);
69466953
var import_universal_user_agent = __nccwpck_require__(3843);
69476954

69486955
// pkg/dist-src/version.js
6949-
var VERSION = "8.4.0";
6956+
var VERSION = "8.4.1";
69506957

69516958
// pkg/dist-src/is-plain-object.js
69526959
function isPlainObject(value) {
@@ -7005,7 +7012,7 @@ function fetchWrapper(requestOptions) {
70057012
headers[keyAndValue[0]] = keyAndValue[1];
70067013
}
70077014
if ("deprecation" in headers) {
7008-
const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/);
7015+
const matches = headers.link && headers.link.match(/<([^<>]+)>; rel="deprecation"/);
70097016
const deprecationLink = matches && matches.pop();
70107017
log.warn(
70117018
`[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${headers.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`
@@ -13009,7 +13016,7 @@ module.exports = {
1300913016

1301013017

1301113018
const { parseSetCookie } = __nccwpck_require__(8915)
13012-
const { stringify, getHeadersList } = __nccwpck_require__(3834)
13019+
const { stringify } = __nccwpck_require__(3834)
1301313020
const { webidl } = __nccwpck_require__(4222)
1301413021
const { Headers } = __nccwpck_require__(6349)
1301513022

@@ -13085,14 +13092,13 @@ function getSetCookies (headers) {
1308513092

1308613093
webidl.brandCheck(headers, Headers, { strict: false })
1308713094

13088-
const cookies = getHeadersList(headers).cookies
13095+
const cookies = headers.getSetCookie()
1308913096

1309013097
if (!cookies) {
1309113098
return []
1309213099
}
1309313100

13094-
// In older versions of undici, cookies is a list of name:value.
13095-
return cookies.map((pair) => parseSetCookie(Array.isArray(pair) ? pair[1] : pair))
13101+
return cookies.map((pair) => parseSetCookie(pair))
1309613102
}
1309713103

1309813104
/**
@@ -13520,14 +13526,15 @@ module.exports = {
1352013526
/***/ }),
1352113527

1352213528
/***/ 3834:
13523-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
13529+
/***/ ((module) => {
1352413530

1352513531
"use strict";
1352613532

1352713533

13528-
const assert = __nccwpck_require__(2613)
13529-
const { kHeadersList } = __nccwpck_require__(6443)
13530-
13534+
/**
13535+
* @param {string} value
13536+
* @returns {boolean}
13537+
*/
1353113538
function isCTLExcludingHtab (value) {
1353213539
if (value.length === 0) {
1353313540
return false
@@ -13788,31 +13795,13 @@ function stringify (cookie) {
1378813795
return out.join('; ')
1378913796
}
1379013797

13791-
let kHeadersListNode
13792-
13793-
function getHeadersList (headers) {
13794-
if (headers[kHeadersList]) {
13795-
return headers[kHeadersList]
13796-
}
13797-
13798-
if (!kHeadersListNode) {
13799-
kHeadersListNode = Object.getOwnPropertySymbols(headers).find(
13800-
(symbol) => symbol.description === 'headers list'
13801-
)
13802-
13803-
assert(kHeadersListNode, 'Headers cannot be parsed')
13804-
}
13805-
13806-
const headersList = headers[kHeadersListNode]
13807-
assert(headersList)
13808-
13809-
return headersList
13810-
}
13811-
1381213798
module.exports = {
1381313799
isCTLExcludingHtab,
13814-
stringify,
13815-
getHeadersList
13800+
validateCookieName,
13801+
validateCookiePath,
13802+
validateCookieValue,
13803+
toIMFDate,
13804+
stringify
1381613805
}
1381713806

1381813807

@@ -15741,6 +15730,14 @@ const { isUint8Array, isArrayBuffer } = __nccwpck_require__(8253)
1574115730
const { File: UndiciFile } = __nccwpck_require__(3041)
1574215731
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(4322)
1574315732

15733+
let random
15734+
try {
15735+
const crypto = __nccwpck_require__(7598)
15736+
random = (max) => crypto.randomInt(0, max)
15737+
} catch {
15738+
random = (max) => Math.floor(Math.random(max))
15739+
}
15740+
1574415741
let ReadableStream = globalThis.ReadableStream
1574515742

1574615743
/** @type {globalThis['File']} */
@@ -15826,7 +15823,7 @@ function extractBody (object, keepalive = false) {
1582615823
// Set source to a copy of the bytes held by object.
1582715824
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
1582815825
} else if (util.isFormDataLike(object)) {
15829-
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
15826+
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
1583015827
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
1583115828

1583215829
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
@@ -17808,6 +17805,7 @@ const {
1780817805
isValidHeaderName,
1780917806
isValidHeaderValue
1781017807
} = __nccwpck_require__(5523)
17808+
const util = __nccwpck_require__(9023)
1781117809
const { webidl } = __nccwpck_require__(4222)
1781217810
const assert = __nccwpck_require__(2613)
1781317811

@@ -18361,6 +18359,9 @@ Object.defineProperties(Headers.prototype, {
1836118359
[Symbol.toStringTag]: {
1836218360
value: 'Headers',
1836318361
configurable: true
18362+
},
18363+
[util.inspect.custom]: {
18364+
enumerable: false
1836418365
}
1836518366
})
1836618367

@@ -27537,6 +27538,20 @@ class Pool extends PoolBase {
2753727538
? { ...options.interceptors }
2753827539
: undefined
2753927540
this[kFactory] = factory
27541+
27542+
this.on('connectionError', (origin, targets, error) => {
27543+
// If a connection error occurs, we remove the client from the pool,
27544+
// and emit a connectionError event. They will not be re-used.
27545+
// Fixes https://github.com/nodejs/undici/issues/3895
27546+
for (const target of targets) {
27547+
// Do not use kRemoveClient here, as it will close the client,
27548+
// but the client cannot be closed in this state.
27549+
const idx = this[kClients].indexOf(target)
27550+
if (idx !== -1) {
27551+
this[kClients].splice(idx, 1)
27552+
}
27553+
}
27554+
})
2754027555
}
2754127556

2754227557
[kGetDispatcher] () {
@@ -29963,6 +29978,8 @@ async function run() {
2996329978
return;
2996429979
}
2996529980
const context = github.context;
29981+
const owner = core.getInput('owner') || context.repo.owner;
29982+
const repo = core.getInput('repo') || context.repo.repo;
2996629983
const issueNumber = parseInt(prNumber) || context.payload.pull_request?.number || context.payload.issue?.number;
2996729984
const octokit = github.getOctokit(githubToken);
2996829985
if (!issueNumber) {
@@ -29972,14 +29989,16 @@ async function run() {
2997229989
const commentTagPattern = `<!-- thollander/actions-comment-pull-request "${commentTag}" -->`;
2997329990
if (commentTagPattern) {
2997429991
for await (const { data: comments } of octokit.paginate.iterator(octokit.rest.issues.listComments, {
29975-
...context.repo,
29992+
owner,
29993+
repo,
2997629994
issue_number: issueNumber,
2997729995
})) {
2997829996
const commentsToDelete = comments.filter((comment) => comment?.body?.includes(commentTagPattern));
2997929997
for (const commentToDelete of commentsToDelete) {
2998029998
core.info(`Deleting comment ${commentToDelete.id}.`);
2998129999
await octokit.rest.issues.deleteComment({
29982-
...context.repo,
30000+
owner,
30001+
repo,
2998330002
comment_id: commentToDelete.id,
2998430003
});
2998530004
}
@@ -30102,6 +30121,14 @@ module.exports = require("net");
3010230121

3010330122
/***/ }),
3010430123

30124+
/***/ 7598:
30125+
/***/ ((module) => {
30126+
30127+
"use strict";
30128+
module.exports = require("node:crypto");
30129+
30130+
/***/ }),
30131+
3010530132
/***/ 8474:
3010630133
/***/ ((module) => {
3010730134

0 commit comments

Comments
 (0)