Merge pull request #698 from jsoref/set-comment-as-output
Set comment as output
This commit is contained in:
+7
-6
@@ -56,10 +56,15 @@ const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
|
|||||||
const octo = new retryingOctokit(githubUtils.getOctokitOptions(core.getInput('repo-token', { required: true })));
|
const octo = new retryingOctokit(githubUtils.getOctokitOptions(core.getInput('repo-token', { required: true })));
|
||||||
// Comment Marker to identify an existing comment to update, so we don't spam the PR with comments
|
// Comment Marker to identify an existing comment to update, so we don't spam the PR with comments
|
||||||
const COMMENT_MARKER = '<!-- dependency-review-pr-comment-marker -->';
|
const COMMENT_MARKER = '<!-- dependency-review-pr-comment-marker -->';
|
||||||
function commentPr(summary) {
|
function commentPr(summary, config) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const commentContent = summary.stringify();
|
const commentContent = summary.stringify();
|
||||||
core.setOutput('comment-content', commentContent);
|
core.setOutput('comment-content', commentContent);
|
||||||
|
if (!(config.comment_summary_in_pr === 'always' ||
|
||||||
|
(config.comment_summary_in_pr === 'on-failure' &&
|
||||||
|
process.exitCode === core.ExitCode.Failure))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!github.context.payload.pull_request) {
|
if (!github.context.payload.pull_request) {
|
||||||
core.warning('Not in the context of a pull request. Skipping comment creation.');
|
core.warning('Not in the context of a pull request. Skipping comment creation.');
|
||||||
return;
|
return;
|
||||||
@@ -648,11 +653,7 @@ function run() {
|
|||||||
}
|
}
|
||||||
summary.addScannedDependencies(changes);
|
summary.addScannedDependencies(changes);
|
||||||
printScannedDependencies(changes);
|
printScannedDependencies(changes);
|
||||||
if (config.comment_summary_in_pr === 'always' ||
|
yield (0, comment_pr_1.commentPr)(core.summary, config);
|
||||||
(config.comment_summary_in_pr === 'on-failure' &&
|
|
||||||
process.exitCode === core.ExitCode.Failure)) {
|
|
||||||
yield (0, comment_pr_1.commentPr)(core.summary);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (error instanceof request_error_1.RequestError && error.status === 404) {
|
if (error instanceof request_error_1.RequestError && error.status === 404) {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+15
-1
@@ -3,6 +3,7 @@ import * as core from '@actions/core'
|
|||||||
import * as githubUtils from '@actions/github/lib/utils'
|
import * as githubUtils from '@actions/github/lib/utils'
|
||||||
import * as retry from '@octokit/plugin-retry'
|
import * as retry from '@octokit/plugin-retry'
|
||||||
import {RequestError} from '@octokit/request-error'
|
import {RequestError} from '@octokit/request-error'
|
||||||
|
import {ConfigurationOptions} from './schemas'
|
||||||
|
|
||||||
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry)
|
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry)
|
||||||
const octo = new retryingOctokit(
|
const octo = new retryingOctokit(
|
||||||
@@ -12,11 +13,24 @@ const octo = new retryingOctokit(
|
|||||||
// Comment Marker to identify an existing comment to update, so we don't spam the PR with comments
|
// Comment Marker to identify an existing comment to update, so we don't spam the PR with comments
|
||||||
const COMMENT_MARKER = '<!-- dependency-review-pr-comment-marker -->'
|
const COMMENT_MARKER = '<!-- dependency-review-pr-comment-marker -->'
|
||||||
|
|
||||||
export async function commentPr(summary: typeof core.summary): Promise<void> {
|
export async function commentPr(
|
||||||
|
summary: typeof core.summary,
|
||||||
|
config: ConfigurationOptions
|
||||||
|
): Promise<void> {
|
||||||
const commentContent = summary.stringify()
|
const commentContent = summary.stringify()
|
||||||
|
|
||||||
core.setOutput('comment-content', commentContent)
|
core.setOutput('comment-content', commentContent)
|
||||||
|
|
||||||
|
if (
|
||||||
|
!(
|
||||||
|
config.comment_summary_in_pr === 'always' ||
|
||||||
|
(config.comment_summary_in_pr === 'on-failure' &&
|
||||||
|
process.exitCode === core.ExitCode.Failure)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!github.context.payload.pull_request) {
|
if (!github.context.payload.pull_request) {
|
||||||
core.warning(
|
core.warning(
|
||||||
'Not in the context of a pull request. Skipping comment creation.'
|
'Not in the context of a pull request. Skipping comment creation.'
|
||||||
|
|||||||
+1
-7
@@ -144,13 +144,7 @@ async function run(): Promise<void> {
|
|||||||
|
|
||||||
summary.addScannedDependencies(changes)
|
summary.addScannedDependencies(changes)
|
||||||
printScannedDependencies(changes)
|
printScannedDependencies(changes)
|
||||||
if (
|
await commentPr(core.summary, config)
|
||||||
config.comment_summary_in_pr === 'always' ||
|
|
||||||
(config.comment_summary_in_pr === 'on-failure' &&
|
|
||||||
process.exitCode === core.ExitCode.Failure)
|
|
||||||
) {
|
|
||||||
await commentPr(core.summary)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof RequestError && error.status === 404) {
|
if (error instanceof RequestError && error.status === 404) {
|
||||||
core.setFailed(
|
core.setFailed(
|
||||||
|
|||||||
Reference in New Issue
Block a user