Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for running inside a matrix by overriding the default correlator identifier #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ jobs:
filePath: "_manifest/spdx_2.2/"
```

Add support for running inside a matrix by overriding the default correlater unique identifier to include the job+matrix values. Consider these sample steps:

```yaml
# Format corrleator as "job(matrixvalue1, matrixvalue2, ... )" or just "job" with a null matrix
- name: Define correlator
id: matrix_parser
run: |
correlator=$(echo '${{ toJSON(matrix) }}' | jq -r 'if . == null then "${{ github.job }}" else "${{ github.job }}(" + ([.[] | tostring] | join(", ")) + ")" end')
echo "correlator=$correlator" >> $GITHUB_OUTPUT

- name: SBOM upload
uses: advanced-security/[email protected]
with:
filePath: "${{ matrix.sbom }}"
correlator: ${{ steps.matrix_parser.outputs.correlator }}
```

## Support

Please create [GitHub Issues][github-issues] if there are bugs or feature requests.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: 'The file name pattern for SPDX files to upload'
required: false
default: '*.spdx.json'
correlator:
description: 'The correlator property itself is the primary field used to keep independent submissions distinct.'
required: false
default: ${{ github.job }}
runs:
using: 'node20'
main: 'dist/index.js'
Expand Down
3 changes: 2 additions & 1 deletion 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.

3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ const VERSION = "0.1.1";
async function run() {
let manifests = lib.getManifestsFromSpdxFiles(lib.searchFiles());

const correlator = core.getInput('correlator');
let snapshot = new toolkit.Snapshot({
name: "spdx-to-dependency-graph-action",
version: VERSION,
url: "https://github.com/advanced-security/spdx-dependency-submission-action",
},
github.context,
{
correlator: `${github.context.job}`,
correlator: correlator,
id: github.context.runId.toString()
});

Expand Down
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.

Loading