add inputs used by autosubmission

This commit is contained in:
E. Lynette Rayle
2025-05-27 22:02:13 +00:00
parent f35d5c9af1
commit f3f97c6024
2 changed files with 50 additions and 3 deletions

View File

@@ -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'

View File

@@ -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)
}