in input-helper, add validation to commit input

Signed-off-by: James Bradlee <james.bradlee@telenor.no>
This commit is contained in:
James Bradlee 2024-08-20 10:49:44 +02:00
parent 8a241b5b4d
commit 267ca9cee1
No known key found for this signature in database

View file

@ -58,6 +58,10 @@ export async function getInputs(): Promise<IGitSourceSettings> {
// Source branch, source version
result.commit = core.getInput('commit')
if (result.commit && !result.commit.match(/^[0-9a-fA-F]{40}$/)) {
throw new Error(`The commit SHA '${result.commit}' is not a valid SHA.`)
}
result.ref = core.getInput('ref') ?? result.commit
if (!result.ref) {
if (isWorkflowRepository) {