mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 14:20:32 +11:00
Merge branch 'main' of https://github.com/mshick/add-pr-comment
This commit is contained in:
commit
a5ba281881
6 changed files with 50 additions and 47 deletions
34
README.md
34
README.md
|
|
@ -62,22 +62,24 @@ jobs:
|
|||
|
||||
## Configuration options
|
||||
|
||||
| Input | Location | Description | Required | Default |
|
||||
| ------------------------ | -------- | ---------------------------------------------------------------------------------------------------- | -------- | ------------------ |
|
||||
| message | with | The message you'd like displayed, supports Markdown and all valid Unicode characters. | maybe | |
|
||||
| message-path | with | Path to a message you'd like displayed. Will be read and displayed just like a normal message. | maybe | |
|
||||
| message-success | with | A message override, printed in case of success. | no | |
|
||||
| message-failure | with | A message override, printed in case of failure. | no | |
|
||||
| message-cancelled | with | A message override, printed in case of cancelled. | no | |
|
||||
| message-skipped | with | A message override, printed in case of skipped. | no | |
|
||||
| status | with | Required if you want to use message status overrides. | no | {{ job.status }} |
|
||||
| repo-token | with | Valid GitHub token, either the temporary token GitHub provides or a personal access token. | no | {{ github.token }} |
|
||||
| message-id | with | Message id to use when searching existing comments. If found, updates the existing (sticky comment). | no | |
|
||||
| refresh-message-position | with | Should the sticky message be the last one in the PR's feed. | no | false |
|
||||
| allow-repeats | with | Boolean flag to allow identical messages to be posted each time this action is run. | no | false |
|
||||
| proxy-url | with | String for your proxy service URL if you'd like this to work with fork-based PRs. | no | |
|
||||
| issue | with | Optional issue number override. | no | |
|
||||
| GITHUB_TOKEN | env | Valid GitHub token, can alternatively be defined in the env. | no | |
|
||||
| Input | Location | Description | Required | Default |
|
||||
|--------------------------|----------|------------------------------------------------------------------------------------------------------|----------|------------------------------------|
|
||||
| message | with | The message you'd like displayed, supports Markdown and all valid Unicode characters. | maybe | |
|
||||
| message-path | with | Path to a message you'd like displayed. Will be read and displayed just like a normal message. | maybe | |
|
||||
| message-success | with | A message override, printed in case of success. | no | |
|
||||
| message-failure | with | A message override, printed in case of failure. | no | |
|
||||
| message-cancelled | with | A message override, printed in case of cancelled. | no | |
|
||||
| message-skipped | with | A message override, printed in case of skipped. | no | |
|
||||
| status | with | Required if you want to use message status overrides. | no | {{ job.status }} |
|
||||
| repo-owner | with | Owner of the repo. | no | {{ github.repository_owner }} |
|
||||
| repo-name | with | Name of the repo. | no | {{ github.event.repository.name }} |
|
||||
| repo-token | with | Valid GitHub token, either the temporary token GitHub provides or a personal access token. | no | {{ github.token }} |
|
||||
| message-id | with | Message id to use when searching existing comments. If found, updates the existing (sticky comment). | no | |
|
||||
| refresh-message-position | with | Should the sticky message be the last one in the PR's feed. | no | false |
|
||||
| allow-repeats | with | Boolean flag to allow identical messages to be posted each time this action is run. | no | false |
|
||||
| proxy-url | with | String for your proxy service URL if you'd like this to work with fork-based PRs. | no | |
|
||||
| issue | with | Optional issue number override. | no | |
|
||||
| GITHUB_TOKEN | env | Valid GitHub token, can alternatively be defined in the env. | no | |
|
||||
|
||||
## Advanced Uses
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ const simpleMessage = 'hello world'
|
|||
type Inputs = {
|
||||
message: string | undefined
|
||||
'message-path': string | undefined
|
||||
'repo-owner': string
|
||||
'repo-name': string
|
||||
'repo-token': string
|
||||
'message-id': string
|
||||
'allow-repeats': string
|
||||
|
|
@ -28,6 +30,8 @@ type Inputs = {
|
|||
const defaultInputs: Inputs = {
|
||||
message: '',
|
||||
'message-path': undefined,
|
||||
'repo-owner': 'foo',
|
||||
'repo-name': 'bar',
|
||||
'repo-token': repoToken,
|
||||
'message-id': 'add-pr-comment',
|
||||
'allow-repeats': 'false',
|
||||
|
|
@ -172,7 +176,7 @@ describe('add-pr-comment action', () => {
|
|||
expect(core.setOutput).toHaveBeenCalledWith('comment-created', 'true')
|
||||
})
|
||||
|
||||
it.only('creates a comment in another repo', async () => {
|
||||
it('creates a comment in another repo', async () => {
|
||||
inputs.message = simpleMessage
|
||||
inputs['repo-owner'] = 'my-owner'
|
||||
inputs['repo-name'] = 'my-repo'
|
||||
|
|
|
|||
|
|
@ -15,6 +15,14 @@ inputs:
|
|||
description: "If a message with the same id, this option allow to refresh the position of the message to be the last one posted."
|
||||
default: "false"
|
||||
required: true
|
||||
repo-owner:
|
||||
description: "The repo owner."
|
||||
default: "${{ github.repository_owner }}"
|
||||
required: true
|
||||
repo-name:
|
||||
description: "The repo name."
|
||||
default: "${{ github.event.repository.name }}"
|
||||
required: true
|
||||
repo-token:
|
||||
description: "A GitHub token for API access. Defaults to {{ github.token }}."
|
||||
default: "${{ github.token }}"
|
||||
|
|
|
|||
18
dist/index.js
vendored
18
dist/index.js
vendored
|
|
@ -99,11 +99,13 @@ const core = __importStar(__nccwpck_require__(2186));
|
|||
const github = __importStar(__nccwpck_require__(5438));
|
||||
const promises_1 = __importDefault(__nccwpck_require__(3977));
|
||||
async function getInputs() {
|
||||
var _a, _b, _c;
|
||||
var _a, _b;
|
||||
const messageIdInput = core.getInput('message-id', { required: false });
|
||||
const messageId = messageIdInput === '' ? 'add-pr-comment' : `add-pr-comment:${messageIdInput}`;
|
||||
const messageInput = core.getInput('message', { required: false });
|
||||
const messagePath = core.getInput('message-path', { required: false });
|
||||
const repoOwner = core.getInput('repo-owner', { required: true });
|
||||
const repoName = core.getInput('repo-name', { required: true });
|
||||
const repoToken = core.getInput('repo-token', { required: true });
|
||||
const status = core.getInput('status', { required: true });
|
||||
const issue = core.getInput('issue', { required: false });
|
||||
|
|
@ -136,11 +138,7 @@ async function getInputs() {
|
|||
throw new Error('no message, check your message inputs');
|
||||
}
|
||||
const { payload } = github.context;
|
||||
const repoFullName = (_a = payload.repository) === null || _a === void 0 ? void 0 : _a.full_name;
|
||||
if (!repoFullName) {
|
||||
throw new Error('unable to determine repository from request type');
|
||||
}
|
||||
const [owner, repo] = repoFullName.split('/');
|
||||
|
||||
return {
|
||||
refreshMessagePosition,
|
||||
allowRepeats,
|
||||
|
|
@ -149,11 +147,11 @@ async function getInputs() {
|
|||
proxyUrl,
|
||||
repoToken,
|
||||
status,
|
||||
issue: issue ? Number(issue) : (_b = payload.issue) === null || _b === void 0 ? void 0 : _b.number,
|
||||
pullRequestNumber: (_c = payload.pull_request) === null || _c === void 0 ? void 0 : _c.number,
|
||||
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,
|
||||
repo,
|
||||
owner: repoOwner || payload.repo.owner,
|
||||
repo: repoName || payload.repo.repo,
|
||||
};
|
||||
}
|
||||
exports.getInputs = getInputs;
|
||||
|
|
|
|||
|
|
@ -31,11 +31,13 @@ const core = __importStar(require("@actions/core"));
|
|||
const github = __importStar(require("@actions/github"));
|
||||
const promises_1 = __importDefault(require("node:fs/promises"));
|
||||
async function getInputs() {
|
||||
var _a, _b, _c;
|
||||
var _a, _b;
|
||||
const messageIdInput = core.getInput('message-id', { required: false });
|
||||
const messageId = messageIdInput === '' ? 'add-pr-comment' : `add-pr-comment:${messageIdInput}`;
|
||||
const messageInput = core.getInput('message', { required: false });
|
||||
const messagePath = core.getInput('message-path', { required: false });
|
||||
const repoOwner = core.getInput('repo-owner', { required: true });
|
||||
const repoName = core.getInput('repo-name', { required: true });
|
||||
const repoToken = core.getInput('repo-token', { required: true });
|
||||
const status = core.getInput('status', { required: true });
|
||||
const issue = core.getInput('issue', { required: false });
|
||||
|
|
@ -72,11 +74,6 @@ async function getInputs() {
|
|||
throw new Error('no message, check your message inputs');
|
||||
}
|
||||
const { payload } = github.context;
|
||||
const repoFullName = (_a = payload.repository) === null || _a === void 0 ? void 0 : _a.full_name;
|
||||
if (!repoFullName) {
|
||||
throw new Error('unable to determine repository from request type');
|
||||
}
|
||||
const [owner, repo] = repoFullName.split('/');
|
||||
return {
|
||||
refreshMessagePosition,
|
||||
allowRepeats,
|
||||
|
|
@ -85,11 +82,11 @@ async function getInputs() {
|
|||
proxyUrl,
|
||||
repoToken,
|
||||
status,
|
||||
issue: issue ? Number(issue) : (_b = payload.issue) === null || _b === void 0 ? void 0 : _b.number,
|
||||
pullRequestNumber: (_c = payload.pull_request) === null || _c === void 0 ? void 0 : _c.number,
|
||||
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,
|
||||
repo,
|
||||
owner: repoOwner || payload.repo.owner,
|
||||
repo: repoName || payload.repo.repo,
|
||||
};
|
||||
}
|
||||
exports.getInputs = getInputs;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ export async function getInputs(): Promise<Inputs> {
|
|||
const messageId = messageIdInput === '' ? 'add-pr-comment' : `add-pr-comment:${messageIdInput}`
|
||||
const messageInput = core.getInput('message', { required: false })
|
||||
const messagePath = core.getInput('message-path', { required: false })
|
||||
const repoOwner = core.getInput('repo-owner', { required: true })
|
||||
const repoName = core.getInput('repo-name', { required: true })
|
||||
const repoToken = core.getInput('repo-token', { required: true })
|
||||
const status = core.getInput('status', { required: true })
|
||||
const issue = core.getInput('issue', { required: false })
|
||||
|
|
@ -73,14 +75,6 @@ export async function getInputs(): Promise<Inputs> {
|
|||
|
||||
const { payload } = github.context
|
||||
|
||||
const repoFullName = payload.repository?.full_name
|
||||
|
||||
if (!repoFullName) {
|
||||
throw new Error('unable to determine repository from request type')
|
||||
}
|
||||
|
||||
const [owner, repo] = repoFullName.split('/')
|
||||
|
||||
return {
|
||||
refreshMessagePosition,
|
||||
allowRepeats,
|
||||
|
|
@ -92,7 +86,7 @@ export async function getInputs(): Promise<Inputs> {
|
|||
issue: issue ? Number(issue) : payload.issue?.number,
|
||||
pullRequestNumber: payload.pull_request?.number,
|
||||
commitSha: github.context.sha,
|
||||
owner,
|
||||
repo,
|
||||
owner: repoOwner || payload.repo.owner,
|
||||
repo: repoName || payload.repo.repo,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue