mirror of
https://github.com/mshick/add-pr-comment.git
synced 2026-01-01 14:49:44 +11:00
new build
This commit is contained in:
parent
4a541a260f
commit
73ffb32342
4 changed files with 3888 additions and 1216 deletions
5017
dist/index.js
vendored
5017
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -22,14 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getInputs = void 0;
|
exports.getInputs = void 0;
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const github = __importStar(require("@actions/github"));
|
const github = __importStar(require("@actions/github"));
|
||||||
const promises_1 = __importDefault(require("node:fs/promises"));
|
const util_1 = require("./util");
|
||||||
async function getInputs() {
|
async function getInputs() {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
const messageIdInput = core.getInput('message-id', { required: false });
|
const messageIdInput = core.getInput('message-id', { required: false });
|
||||||
|
|
@ -45,12 +42,12 @@ async function getInputs() {
|
||||||
const allowRepeats = core.getInput('allow-repeats', { required: true }) === 'true';
|
const allowRepeats = core.getInput('allow-repeats', { required: true }) === 'true';
|
||||||
const refreshMessagePosition = core.getInput('refresh-message-position', { required: false }) === 'true';
|
const refreshMessagePosition = core.getInput('refresh-message-position', { required: false }) === 'true';
|
||||||
const updateOnly = core.getInput('update-only', { required: false }) === 'true';
|
const updateOnly = core.getInput('update-only', { required: false }) === 'true';
|
||||||
if (messageInput && messagePath) {
|
if (messageInput && messagePath.length) {
|
||||||
throw new Error('must specify only one, message or message-path');
|
throw new Error('must specify only one, message or message-path');
|
||||||
}
|
}
|
||||||
let message;
|
let message;
|
||||||
if (messagePath) {
|
if (messagePath.length) {
|
||||||
message = await promises_1.default.readFile(messagePath, { encoding: 'utf8' });
|
message = await (0, util_1.getMessageFromPaths)(messagePath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
message = messageInput;
|
message = messageInput;
|
||||||
|
|
@ -76,16 +73,16 @@ async function getInputs() {
|
||||||
}
|
}
|
||||||
const { payload } = github.context;
|
const { payload } = github.context;
|
||||||
return {
|
return {
|
||||||
refreshMessagePosition,
|
|
||||||
allowRepeats,
|
allowRepeats,
|
||||||
|
commitSha: github.context.sha,
|
||||||
|
issue: issue ? Number(issue) : (_a = payload.issue) === null || _a === void 0 ? void 0 : _a.number,
|
||||||
message,
|
message,
|
||||||
messageId: `<!-- ${messageId} -->`,
|
messageId: `<!-- ${messageId} -->`,
|
||||||
proxyUrl,
|
proxyUrl,
|
||||||
|
pullRequestNumber: (_b = payload.pull_request) === null || _b === void 0 ? void 0 : _b.number,
|
||||||
|
refreshMessagePosition,
|
||||||
repoToken,
|
repoToken,
|
||||||
status,
|
status,
|
||||||
issue: issue ? Number(issue) : (_a = payload.issue) === null || _a === void 0 ? void 0 : _a.number,
|
|
||||||
pullRequestNumber: (_b = payload.pull_request) === null || _b === void 0 ? void 0 : _b.number,
|
|
||||||
commitSha: github.context.sha,
|
|
||||||
owner: repoOwner || payload.repo.owner,
|
owner: repoOwner || payload.repo.owner,
|
||||||
repo: repoName || payload.repo.repo,
|
repo: repoName || payload.repo.repo,
|
||||||
updateOnly: updateOnly,
|
updateOnly: updateOnly,
|
||||||
|
|
|
||||||
68
lib/util.js
Normal file
68
lib/util.js
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.findFiles = exports.getMessageFromPaths = void 0;
|
||||||
|
const core = __importStar(require("@actions/core"));
|
||||||
|
const glob = __importStar(require("@actions/glob"));
|
||||||
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
||||||
|
async function getMessageFromPaths(searchPath) {
|
||||||
|
let message = '';
|
||||||
|
const files = await findFiles(searchPath);
|
||||||
|
for (const [index, path] of files.entries()) {
|
||||||
|
if (index > 0) {
|
||||||
|
message += '\n';
|
||||||
|
}
|
||||||
|
message += await promises_1.default.readFile(path, { encoding: 'utf8' });
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
exports.getMessageFromPaths = getMessageFromPaths;
|
||||||
|
function getDefaultGlobOptions() {
|
||||||
|
return {
|
||||||
|
followSymbolicLinks: true,
|
||||||
|
implicitDescendants: true,
|
||||||
|
omitBrokenSymbolicLinks: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
async function findFiles(searchPath, globOptions) {
|
||||||
|
const searchResults = [];
|
||||||
|
const globber = await glob.create(searchPath, globOptions || getDefaultGlobOptions());
|
||||||
|
const rawSearchResults = await globber.glob();
|
||||||
|
for (const searchResult of rawSearchResults) {
|
||||||
|
const fileStats = await promises_1.default.stat(searchResult);
|
||||||
|
if (!fileStats.isDirectory()) {
|
||||||
|
core.debug(`File: ${searchResult} was found using the provided searchPath`);
|
||||||
|
searchResults.push(searchResult);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.debug(`Removing ${searchResult} from rawSearchResults because it is a directory`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return searchResults;
|
||||||
|
}
|
||||||
|
exports.findFiles = findFiles;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue