Skip to content

Commit

Permalink
don't set output on every run
Browse files Browse the repository at this point in the history
  • Loading branch information
febuiles committed Feb 20, 2024
1 parent a1be843 commit 9129d7d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 25 deletions.
13 changes: 6 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "dependency-review-action",
"version": "4.1.2",
"version": "4.1.3",
"private": true,
"description": "A GitHub Action for Dependency Review",
"main": "lib/main.js",
Expand Down
14 changes: 1 addition & 13 deletions src/comment-pr.ts
Expand Up @@ -3,7 +3,6 @@ import * as core from '@actions/core'
import * as githubUtils from '@actions/github/lib/utils'
import * as retry from '@octokit/plugin-retry'
import {RequestError} from '@octokit/request-error'
import {ConfigurationOptions} from './schemas'

const retryingOctokit = githubUtils.GitHub.plugin(retry.retry)
const octo = new retryingOctokit(
Expand All @@ -13,22 +12,11 @@ const octo = new retryingOctokit(
// 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 -->'

export async function commentPr(
summary: typeof core.summary,
config: ConfigurationOptions
): Promise<void> {
export async function commentPr(summary: typeof core.summary): Promise<void> {
const commentContent = summary.stringify()

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) {
core.warning(
'Not in the context of a pull request. Skipping comment creation.'
Expand Down
8 changes: 7 additions & 1 deletion src/main.ts
Expand Up @@ -144,7 +144,13 @@ async function run(): Promise<void> {

summary.addScannedDependencies(changes)
printScannedDependencies(changes)
await commentPr(core.summary, config)
if (
config.comment_summary_in_pr === 'always' ||
(config.comment_summary_in_pr === 'on-failure' &&
process.exitCode === core.ExitCode.Failure)
) {
await commentPr(core.summary)
}
} catch (error) {
if (error instanceof RequestError && error.status === 404) {
core.setFailed(
Expand Down

0 comments on commit 9129d7d

Please sign in to comment.