From f3f97c60246e603bb6119a7caa791e2ed2906054 Mon Sep 17 00:00:00 2001 From: "E. Lynette Rayle" Date: Tue, 27 May 2025 22:02:13 +0000 Subject: [PATCH] add inputs used by autosubmission --- action.yml | 24 ++++++++++++++++++++++++ src/index.ts | 29 ++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 90d44e8..491b7e3 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,30 @@ inputs: required: true description: 'Build target to detect build dependencies. If unspecified, will use "all", with will detect all dependencies used in all build targets (including tests and tools).' default: 'all' + snapshot-sha: + description: The SHA that the results will be linked to in the dependency snapshot + type: string + required: false + default: '' + snapshot-ref: + description: The ref that the results will be linked to in the dependency snapshot + type: string + required: false + default: '' + + # If any of detector-name, detector-version, or detector-url are provided, they all have to be provided. Defaults will be used if any are not provided. + detector-name: + description: The name of the detector that generated the dependency snapshot + type: string + required: false + detector-version: + description: The version of the detector that generated the dependency snapshot + type: string + required: false + detector-url: + description: The URL to the detector that generated the dependency snapshot + type: string + required: false runs: using: 'node20' main: 'dist/index.js' diff --git a/src/index.ts b/src/index.ts index 4031cb7..cefdff4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -77,12 +77,32 @@ async function main () { manifest.addIndirectDependency(dep) }) - const snapshot = new Snapshot( - { + type SnapshotDetector = { + name: string; + url: string; + version: string; + }; + var snapshotDetector: SnapshotDetector; + + // If detector name is passed in, then url and version are required inputs + // Otherwise, default values will be used to maintain backwards compatibility + const detectorName = core.getInput('detector-name'); + if (detectorName !== '') { + snapshotDetector = { + name: detectorName, + url: core.getInput('detector-url', { required: true }), + version: core.getInput('detector-version', { required: true }) + } + } else { + snapshotDetector = { name: 'actions/go-dependency-submission', url: 'https://github.com/actions/go-dependency-submission', version: '0.0.1' - }, + } + } + + const snapshot = new Snapshot( + snapshotDetector, github.context, { correlator: `${github.context.job}-${goBuildTarget}`, @@ -90,6 +110,9 @@ async function main () { } ) snapshot.addManifest(manifest) + snapshot.sha = core.getInput('snapshot-sha') + snapshot.ref = core.getInput('snapshot-ref') + submitSnapshot(snapshot) }