Adding ability to specify the SHA and Ref for snapshot
This commit is contained in:
+13
@@ -40,6 +40,19 @@ inputs:
|
||||
type: string
|
||||
default: ${{ github.token }}
|
||||
|
||||
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 tha tthe results will be linked to in the dependency snapshot
|
||||
type: string
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
|
||||
runs:
|
||||
using: node16
|
||||
main: dist/index.js
|
||||
|
||||
Vendored
+24
-3
@@ -245,9 +245,13 @@ function run() {
|
||||
settingsFile: core.getInput('settings-file'),
|
||||
mavenArgs: core.getInput('maven-args') || '',
|
||||
};
|
||||
const includeFilename = core.getBooleanInput('snapshot-include-file-name');
|
||||
const manifestFilename = core.getInput('snapshot-dependency-file-name');
|
||||
snapshot = yield (0, snapshot_generator_1.generateSnapshot)(directory, mavenConfig, { includeManifestFile: includeFilename, manifestFile: manifestFilename });
|
||||
const snapshotConfig = {
|
||||
includeManifestFile: core.getBooleanInput('snapshot-include-file-name'),
|
||||
manifestFile: core.getInput('snapshot-dependency-file-name'),
|
||||
targetSHA: core.getInput('snapshot-sha'),
|
||||
targetRef: core.getInput('snapshot-ref'),
|
||||
};
|
||||
snapshot = yield (0, snapshot_generator_1.generateSnapshot)(directory, mavenConfig, snapshotConfig);
|
||||
}
|
||||
catch (err) {
|
||||
core.error(err);
|
||||
@@ -491,6 +495,14 @@ function generateSnapshot(directory, mvnConfig, snapshotConfig) {
|
||||
}
|
||||
const snapshot = new dependency_submission_toolkit_1.Snapshot(getDetector(), snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.context, snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.job);
|
||||
snapshot.addManifest(manifest);
|
||||
const specifiedRef = getNonEmtptyValue(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.ref);
|
||||
if (specifiedRef) {
|
||||
snapshot.ref = specifiedRef;
|
||||
}
|
||||
const specifiedSha = getNonEmtptyValue(snapshot === null || snapshot === void 0 ? void 0 : snapshot.sha);
|
||||
if (specifiedSha) {
|
||||
snapshot.sha = specifiedSha;
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
catch (err) {
|
||||
@@ -587,6 +599,15 @@ function getRepositoryRelativePath(file) {
|
||||
core.debug(`Snapshot relative file = ${result}`);
|
||||
return result;
|
||||
}
|
||||
function getNonEmtptyValue(str) {
|
||||
if (str) {
|
||||
const trimmed = str.trim();
|
||||
if (trimmed.length > 0) {
|
||||
return trimmed;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
//# sourceMappingURL=snapshot-generator.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+7
-3
@@ -12,10 +12,14 @@ async function run() {
|
||||
settingsFile: core.getInput('settings-file'),
|
||||
mavenArgs: core.getInput('maven-args') || '',
|
||||
}
|
||||
const includeFilename = core.getBooleanInput('snapshot-include-file-name');
|
||||
const manifestFilename = core.getInput('snapshot-dependency-file-name');
|
||||
const snapshotConfig = {
|
||||
includeManifestFile: core.getBooleanInput('snapshot-include-file-name'),
|
||||
manifestFile: core.getInput('snapshot-dependency-file-name'),
|
||||
targetSHA: core.getInput('snapshot-sha'),
|
||||
targetRef: core.getInput('snapshot-ref'),
|
||||
}
|
||||
|
||||
snapshot = await generateSnapshot(directory, mavenConfig, {includeManifestFile: includeFilename, manifestFile: manifestFilename});
|
||||
snapshot = await generateSnapshot(directory, mavenConfig, snapshotConfig);
|
||||
} catch (err: any) {
|
||||
core.error(err);
|
||||
core.setFailed(`Failed to generate a dependency snapshot, check logs for more details, ${err}`);
|
||||
|
||||
@@ -20,7 +20,9 @@ export type SnapshotConfig = {
|
||||
includeManifestFile?: boolean;
|
||||
manifestFile?: string;
|
||||
context?: any;
|
||||
job?: any
|
||||
job?: any;
|
||||
sha?: any;
|
||||
ref?: any;
|
||||
};
|
||||
|
||||
export async function generateSnapshot(directory: string, mvnConfig?: MavenConfiguration, snapshotConfig?: SnapshotConfig) {
|
||||
@@ -46,6 +48,16 @@ export async function generateSnapshot(directory: string, mvnConfig?: MavenConfi
|
||||
const snapshot = new Snapshot(getDetector(), snapshotConfig?.context, snapshotConfig?.job);
|
||||
snapshot.addManifest(manifest);
|
||||
|
||||
const specifiedRef = getNonEmtptyValue(snapshotConfig?.ref);
|
||||
if (specifiedRef) {
|
||||
snapshot.ref = specifiedRef;
|
||||
}
|
||||
|
||||
const specifiedSha = getNonEmtptyValue(snapshot?.sha);
|
||||
if (specifiedSha) {
|
||||
snapshot.sha = specifiedSha;
|
||||
}
|
||||
|
||||
return snapshot;
|
||||
} catch (err: any) {
|
||||
core.error(err);
|
||||
@@ -149,4 +161,14 @@ function getRepositoryRelativePath(file) {
|
||||
|
||||
core.debug(`Snapshot relative file = ${result}`);
|
||||
return result;
|
||||
}
|
||||
|
||||
function getNonEmtptyValue(str?: string) {
|
||||
if (str) {
|
||||
const trimmed = str.trim();
|
||||
if (trimmed.length > 0) {
|
||||
return trimmed;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user