diff --git a/action.yml b/action.yml index ec5b0d17..d120f55d 100644 --- a/action.yml +++ b/action.yml @@ -69,7 +69,7 @@ inputs: default: true dependency-graph: - description: Specifies if a GitHub dependency snapshot should be generated for each Gradle build, and if so, how. Valid values are 'disabled' (default), 'generate', 'generate-and-submit' and 'download-and-submit'. + description: Specifies if a GitHub dependency snapshot should be generated for each Gradle build, and if so, how. Valid values are 'disabled' (default), 'generate', 'generate-and-submit', 'download-and-submit' and 'clear'. required: false default: 'disabled' diff --git a/src/dependency-graph.ts b/src/dependency-graph.ts index 4f61881c..2f8090db 100644 --- a/src/dependency-graph.ts +++ b/src/dependency-graph.ts @@ -36,6 +36,12 @@ export async function setup(option: DependencyGraphOption): Promise { 'DEPENDENCY_GRAPH_REPORT_DIR', path.resolve(layout.workspaceDirectory(), 'dependency-graph-reports') ) + + // To clear the dependency graph, we generate an empty graph by excluding all projects and configurations + if (option === DependencyGraphOption.Clear) { + core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_PROJECTS', '') + core.exportVariable('DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS', '') + } } export async function complete(option: DependencyGraphOption): Promise { @@ -47,6 +53,7 @@ export async function complete(option: DependencyGraphOption): Promise { await uploadDependencyGraphs() return case DependencyGraphOption.GenerateAndSubmit: + case DependencyGraphOption.Clear: // Submit the empty dependency graph await submitDependencyGraphs(await uploadDependencyGraphs()) return } diff --git a/src/input-params.ts b/src/input-params.ts index 06c2262b..c1aa9671 100644 --- a/src/input-params.ts +++ b/src/input-params.ts @@ -82,6 +82,8 @@ export function getDependencyGraphOption(): DependencyGraphOption { return DependencyGraphOption.GenerateAndSubmit case 'download-and-submit': return DependencyGraphOption.DownloadAndSubmit + case 'clear': + return DependencyGraphOption.Clear } throw TypeError( `The value '${val} is not valid for 'dependency-graph. Valid values are: [disabled, generate-and-upload, generate-and-submit, download-and-submit]. The default value is 'disabled'.` @@ -122,5 +124,6 @@ export enum DependencyGraphOption { Disabled, Generate, GenerateAndSubmit, - DownloadAndSubmit + DownloadAndSubmit, + Clear }