Merge pull request #707 from laughedelic/feat/data-outputs
Add outputs for the changes data
This commit is contained in:
@@ -161,7 +161,26 @@ The Dependency Review GitHub Action check will only block a pull request from be
|
|||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
`comment-content` is generated with the same content as would be present in a Dependency Review Action comment.
|
- `comment-content` is generated with the same content as would be present in a Dependency Review Action comment.
|
||||||
|
- `dependency-changes` holds all dependency changes in a JSON format. The following outputs are subsets of `dependency-changes` filtered based on the configuration:
|
||||||
|
- `vulnerable-changes` holds information about dependency changes with vulnerable dependencies in a JSON format.
|
||||||
|
- `invalid-license-changes` holds information about invalid or non-compliant license dependency changes in a JSON format.
|
||||||
|
- `denied-changes` holds information about denied dependency changes in a JSON format.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Action outputs are unicode strings [with a 1MB size limit](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputs-for-docker-container-and-javascript-actions).
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If you use these outputs in a run-step, you must store the ouput data in an envrioment variable instead of using the output directly. Using an output directly might break shell scripts. For example:
|
||||||
|
>
|
||||||
|
> ```yaml
|
||||||
|
> env:
|
||||||
|
> VULNERABLE_CHANGES: ${{ steps.review.outputs.vulnerable-changes }}
|
||||||
|
> run: |
|
||||||
|
> echo "$VULNERABLE_CHANGES" | jq
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> instead of direct `echo '${{ steps.review.outputs.vulnerable-changes }}'`. See [examples](docs/examples.md) for more.
|
||||||
|
|
||||||
## Getting help
|
## Getting help
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,14 @@ inputs:
|
|||||||
outputs:
|
outputs:
|
||||||
comment-content:
|
comment-content:
|
||||||
description: Prepared dependency report comment
|
description: Prepared dependency report comment
|
||||||
|
dependency-changes:
|
||||||
|
description: All dependency changes (JSON)
|
||||||
|
vulnerable-changes:
|
||||||
|
description: Vulnerable dependency changes (JSON)
|
||||||
|
invalid-license-changes:
|
||||||
|
description: Invalid license dependency changes (JSON)
|
||||||
|
denied-changes:
|
||||||
|
description: Denied dependency changes (JSON)
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
|
|||||||
+4
@@ -642,14 +642,17 @@ function run() {
|
|||||||
summary.addSnapshotWarnings(config, snapshot_warnings);
|
summary.addSnapshotWarnings(config, snapshot_warnings);
|
||||||
}
|
}
|
||||||
if (config.vulnerability_check) {
|
if (config.vulnerability_check) {
|
||||||
|
core.setOutput('vulnerable-changes', JSON.stringify(vulnerableChanges));
|
||||||
summary.addChangeVulnerabilitiesToSummary(vulnerableChanges, minSeverity);
|
summary.addChangeVulnerabilitiesToSummary(vulnerableChanges, minSeverity);
|
||||||
printVulnerabilitiesBlock(vulnerableChanges, minSeverity, warnOnly);
|
printVulnerabilitiesBlock(vulnerableChanges, minSeverity, warnOnly);
|
||||||
}
|
}
|
||||||
if (config.license_check) {
|
if (config.license_check) {
|
||||||
|
core.setOutput('invalid-license-changes', JSON.stringify(invalidLicenseChanges));
|
||||||
summary.addLicensesToSummary(invalidLicenseChanges, config);
|
summary.addLicensesToSummary(invalidLicenseChanges, config);
|
||||||
printLicensesBlock(invalidLicenseChanges, warnOnly);
|
printLicensesBlock(invalidLicenseChanges, warnOnly);
|
||||||
}
|
}
|
||||||
if (config.deny_packages || config.deny_groups) {
|
if (config.deny_packages || config.deny_groups) {
|
||||||
|
core.setOutput('denied-changes', JSON.stringify(deniedChanges));
|
||||||
summary.addDeniedToSummary(deniedChanges);
|
summary.addDeniedToSummary(deniedChanges);
|
||||||
printDeniedDependencies(deniedChanges, config);
|
printDeniedDependencies(deniedChanges, config);
|
||||||
}
|
}
|
||||||
@@ -658,6 +661,7 @@ function run() {
|
|||||||
printScorecardBlock(scorecard, config);
|
printScorecardBlock(scorecard, config);
|
||||||
createScorecardWarnings(scorecard, config);
|
createScorecardWarnings(scorecard, config);
|
||||||
}
|
}
|
||||||
|
core.setOutput('dependency-changes', JSON.stringify(changes));
|
||||||
summary.addScannedDependencies(changes);
|
summary.addScannedDependencies(changes);
|
||||||
printScannedDependencies(changes);
|
printScannedDependencies(changes);
|
||||||
yield (0, comment_pr_1.commentPr)(core.summary, config);
|
yield (0, comment_pr_1.commentPr)(core.summary, config);
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+14
-5
@@ -166,7 +166,8 @@ jobs:
|
|||||||
|
|
||||||
## Getting the results of the action in a later step
|
## Getting the results of the action in a later step
|
||||||
|
|
||||||
Using the `comment-content` output you can get the results of the action in a workflow step.
|
- `comment-content` contains the output of the results comment for the entire run.
|
||||||
|
`dependency-changes`, `vulnerable-changes`, `invalid-license-changes` and `denied-changes` are all JSON objects that allow you to access individual sets of changes.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: 'Dependency Review'
|
name: 'Dependency Review'
|
||||||
@@ -192,10 +193,18 @@ jobs:
|
|||||||
# make sure this step runs even if the previous failed
|
# make sure this step runs even if the previous failed
|
||||||
if: ${{ failure() && steps.review.conclusion == 'failure' }}
|
if: ${{ failure() && steps.review.conclusion == 'failure' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env: # store comment HTML data in an environment variable
|
||||||
comment: ${{ steps.review.outputs.comment-content }}
|
COMMENT: ${{ steps.review.outputs.comment-content }}
|
||||||
run: |
|
run: | # do something with the comment:
|
||||||
echo "$comment" # do something with the comment
|
echo "$COMMENT"
|
||||||
|
- name: 'List vulnerable dependencies'
|
||||||
|
# make sure this step runs even if the previous failed
|
||||||
|
if: ${{ failure() && steps.review.conclusion == 'failure' }}
|
||||||
|
shell: bash
|
||||||
|
env: # store JSON data in an environment variable
|
||||||
|
VULNERABLE_CHANGES: ${{ steps.review.outputs.vulnerable-changes }}
|
||||||
|
run: | # do something with the JSON:
|
||||||
|
echo "$VULNERABLE_CHANGES" | jq '.[].package_url'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Exclude dependencies from the license check
|
## Exclude dependencies from the license check
|
||||||
|
|||||||
@@ -140,14 +140,20 @@ async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.vulnerability_check) {
|
if (config.vulnerability_check) {
|
||||||
|
core.setOutput('vulnerable-changes', JSON.stringify(vulnerableChanges))
|
||||||
summary.addChangeVulnerabilitiesToSummary(vulnerableChanges, minSeverity)
|
summary.addChangeVulnerabilitiesToSummary(vulnerableChanges, minSeverity)
|
||||||
printVulnerabilitiesBlock(vulnerableChanges, minSeverity, warnOnly)
|
printVulnerabilitiesBlock(vulnerableChanges, minSeverity, warnOnly)
|
||||||
}
|
}
|
||||||
if (config.license_check) {
|
if (config.license_check) {
|
||||||
|
core.setOutput(
|
||||||
|
'invalid-license-changes',
|
||||||
|
JSON.stringify(invalidLicenseChanges)
|
||||||
|
)
|
||||||
summary.addLicensesToSummary(invalidLicenseChanges, config)
|
summary.addLicensesToSummary(invalidLicenseChanges, config)
|
||||||
printLicensesBlock(invalidLicenseChanges, warnOnly)
|
printLicensesBlock(invalidLicenseChanges, warnOnly)
|
||||||
}
|
}
|
||||||
if (config.deny_packages || config.deny_groups) {
|
if (config.deny_packages || config.deny_groups) {
|
||||||
|
core.setOutput('denied-changes', JSON.stringify(deniedChanges))
|
||||||
summary.addDeniedToSummary(deniedChanges)
|
summary.addDeniedToSummary(deniedChanges)
|
||||||
printDeniedDependencies(deniedChanges, config)
|
printDeniedDependencies(deniedChanges, config)
|
||||||
}
|
}
|
||||||
@@ -157,6 +163,7 @@ async function run(): Promise<void> {
|
|||||||
createScorecardWarnings(scorecard, config)
|
createScorecardWarnings(scorecard, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.setOutput('dependency-changes', JSON.stringify(changes))
|
||||||
summary.addScannedDependencies(changes)
|
summary.addScannedDependencies(changes)
|
||||||
printScannedDependencies(changes)
|
printScannedDependencies(changes)
|
||||||
await commentPr(core.summary, config)
|
await commentPr(core.summary, config)
|
||||||
|
|||||||
Reference in New Issue
Block a user