mirror of
https://github.com/mshick/add-pr-comment.git
synced 2026-01-01 14:49:44 +11:00
adds support for message-path (#58)
This commit is contained in:
parent
841d232c5a
commit
cd100c8b09
8 changed files with 110 additions and 19 deletions
17
lib/main.js
17
lib/main.js
|
|
@ -22,10 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
__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 });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const github = __importStar(require("@actions/github"));
|
||||
const http_client_1 = require("@actions/http-client");
|
||||
const promises_1 = __importDefault(require("node:fs/promises"));
|
||||
const listCommitPulls = async (params) => {
|
||||
const { repoToken, owner, repo, commitSha } = params;
|
||||
const http = new http_client_1.HttpClient('http-client-add-pr-comment');
|
||||
|
|
@ -60,6 +64,7 @@ const getInputs = () => {
|
|||
return {
|
||||
allowRepeats: Boolean(core.getInput('allow-repeats') === 'true'),
|
||||
message: core.getInput('message'),
|
||||
messagePath: core.getInput('message-path'),
|
||||
proxyUrl: core.getInput('proxy-url').replace(/\/$/, ''),
|
||||
repoToken: core.getInput('repo-token') || process.env['GITHUB_TOKEN'],
|
||||
repoTokenUserLogin: core.getInput('repo-token-user-login'),
|
||||
|
|
@ -67,10 +72,20 @@ const getInputs = () => {
|
|||
};
|
||||
const run = async () => {
|
||||
try {
|
||||
const { allowRepeats, message, repoToken, repoTokenUserLogin, proxyUrl } = getInputs();
|
||||
const { allowRepeats, message, messagePath, repoToken, repoTokenUserLogin, proxyUrl } = getInputs();
|
||||
if (!repoToken) {
|
||||
throw new Error('no github token provided, set one with the repo-token input or GITHUB_TOKEN env variable');
|
||||
}
|
||||
if (message && messagePath) {
|
||||
throw new Error('must specify only one, message or message-path');
|
||||
}
|
||||
let messageText = message;
|
||||
if (messagePath) {
|
||||
messageText = await promises_1.default.readFile(messagePath, { encoding: 'utf8' });
|
||||
}
|
||||
if (!messageText) {
|
||||
throw new Error('could not get message text, check your message-path');
|
||||
}
|
||||
const { payload: { pull_request: pullRequest, issue, repository }, sha: commitSha, } = github.context;
|
||||
if (!repository) {
|
||||
core.info('unable to determine repository from request type');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue