revert to directly using input for sha and ref and allowing the context to drive them if they are missing
This commit is contained in:
+3
-27
@@ -7,7 +7,6 @@ import {
|
|||||||
Manifest,
|
Manifest,
|
||||||
submitSnapshot
|
submitSnapshot
|
||||||
} from '@github/dependency-submission-toolkit'
|
} from '@github/dependency-submission-toolkit'
|
||||||
import type { PullRequestEvent } from '@octokit/webhooks-types'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
processGoGraph,
|
processGoGraph,
|
||||||
@@ -96,11 +95,7 @@ async function main () {
|
|||||||
url: 'https://github.com/actions/go-dependency-submission',
|
url: 'https://github.com/actions/go-dependency-submission',
|
||||||
version: '0.0.1'
|
version: '0.0.1'
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (detectorName === '' || detectorUrl === '' || detectorVersion === '') {
|
||||||
detectorName === '' ||
|
|
||||||
detectorUrl === '' ||
|
|
||||||
detectorVersion === ''
|
|
||||||
) {
|
|
||||||
// if any of detectorName, detectorUrl, or detectorVersion have value, then they are all required
|
// if any of detectorName, detectorUrl, or detectorVersion have value, then they are all required
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Invalid input: if any of 'detector-name', 'detector-url', or 'detector-version' have value, then thay are all required."
|
"Invalid input: if any of 'detector-name', 'detector-url', or 'detector-version' have value, then thay are all required."
|
||||||
@@ -119,29 +114,10 @@ async function main () {
|
|||||||
id: github.context.runId.toString()
|
id: github.context.runId.toString()
|
||||||
})
|
})
|
||||||
snapshot.addManifest(manifest)
|
snapshot.addManifest(manifest)
|
||||||
snapshot.sha = core.getInput('snapshot-sha') && getShaFromContext()
|
snapshot.sha = core.getInput('snapshot-sha')
|
||||||
snapshot.ref = core.getInput('snapshot-ref') && github.context.ref
|
snapshot.ref = core.getInput('snapshot-ref')
|
||||||
|
|
||||||
submitSnapshot(snapshot)
|
submitSnapshot(snapshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getShaFromContext (): string {
|
|
||||||
const context = github.context
|
|
||||||
const pullRequestEvents = [
|
|
||||||
'pull_request',
|
|
||||||
'pull_request_comment',
|
|
||||||
'pull_request_review',
|
|
||||||
'pull_request_review_comment'
|
|
||||||
// Note that pull_request_target is omitted here.
|
|
||||||
// That event runs in the context of the base commit of the PR,
|
|
||||||
// so the snapshot should not be associated with the head commit.
|
|
||||||
]
|
|
||||||
if (pullRequestEvents.includes(context.eventName)) {
|
|
||||||
const pr = (context.payload as PullRequestEvent).pull_request
|
|
||||||
return pr.head.sha
|
|
||||||
} else {
|
|
||||||
return context.sha
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user