Skip to content

Commit d49697a

Browse files
committed
Make source-and-binaries-glob optional
1 parent bc49dda commit d49697a

5 files changed

Lines changed: 34 additions & 12 deletions

File tree

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inputs:
1212
description: 'the ID of a project (an integer) created in Code Dx'
1313
required: true
1414
source-and-binaries-glob:
15-
description: 'a file glob matching source and binary files (accepts multiple comma-separated globs)'
15+
description: 'a file glob matching source and binary files (accepts multiple comma-separated globs). if not set, no source/binary files will be sent to Code Dx'
1616
required: true
1717
tool-outputs-glob:
1818
description: 'a file glob matching output files (ie scan results) from an analysis tool (accepts multiple comma-separated globs)'

analyze.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,19 @@ module.exports = async function run() {
126126

127127
const formData = new FormData()
128128

129-
core.info("Preparing source/binaries ZIP...")
130-
await attachInputsZip(config.inputGlobs, formData, config.tmpDir)
129+
if (config.inputGlobs) {
130+
core.info("Preparing source/binaries ZIP...")
131+
await attachInputsZip(config.inputGlobs, formData, config.tmpDir)
132+
} else {
133+
core.info("Source/binary inputs glob not specified, skipping ZIP creation")
134+
}
131135

132-
core.info("Adding scan files...")
133-
await attachScanFiles(config.scanGlobs, formData)
136+
if (!config.scanGlobs) {
137+
core.info("Adding scan files...")
138+
await attachScanFiles(config.scanGlobs, formData)
139+
} else {
140+
core.info("Scan files glob not specified, skipping scan file attachment")
141+
}
134142

135143
core.info("Uploading to Code Dx...")
136144
const { analysisId, jobId } = await client.runAnalysis(config.projectId, formData)

config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Config {
1717
this.serverUrl = core.getInput('server-url', { required: true })
1818
this.apiKey = core.getInput('api-key', { required: true })
1919
this.projectId = core.getInput('project-id', { required: true })
20-
this.inputGlobs = core.getInput('source-and-binaries-glob', { required: true })
20+
this.inputGlobs = core.getInput('source-and-binaries-glob')
2121
this.scanGlobs = core.getInput('tool-outputs-glob')
2222

2323
this.waitForCompletion = core.getInput('wait-for-completion')
@@ -31,6 +31,9 @@ class Config {
3131
sanitize() {
3232
fixBoolean(this, 'waitForCompletion')
3333
fixBoolean(this, 'dryRun')
34+
fixBoolean(this, 'requireInputFiles')
35+
36+
this.inputGlobs = this.inputGlobs.trim()
3437

3538
if (typeof this.projectId != 'number') {
3639
try {

dist/index.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,19 @@ module.exports = async function run() {
133133

134134
const formData = new FormData()
135135

136-
core.info("Preparing source/binaries ZIP...")
137-
await attachInputsZip(config.inputGlobs, formData, config.tmpDir)
136+
if (config.inputGlobs) {
137+
core.info("Preparing source/binaries ZIP...")
138+
await attachInputsZip(config.inputGlobs, formData, config.tmpDir)
139+
} else {
140+
core.info("Source/binary inputs glob not specified, skipping ZIP creation")
141+
}
138142

139-
core.info("Adding scan files...")
140-
await attachScanFiles(config.scanGlobs, formData)
143+
if (!config.scanGlobs) {
144+
core.info("Adding scan files...")
145+
await attachScanFiles(config.scanGlobs, formData)
146+
} else {
147+
core.info("Scan files glob not specified, skipping scan file attachment")
148+
}
141149

142150
core.info("Uploading to Code Dx...")
143151
const { analysisId, jobId } = await client.runAnalysis(config.projectId, formData)
@@ -314,7 +322,7 @@ class Config {
314322
this.serverUrl = core.getInput('server-url', { required: true })
315323
this.apiKey = core.getInput('api-key', { required: true })
316324
this.projectId = core.getInput('project-id', { required: true })
317-
this.inputGlobs = core.getInput('source-and-binaries-glob', { required: true })
325+
this.inputGlobs = core.getInput('source-and-binaries-glob')
318326
this.scanGlobs = core.getInput('tool-outputs-glob')
319327

320328
this.waitForCompletion = core.getInput('wait-for-completion')
@@ -328,6 +336,9 @@ class Config {
328336
sanitize() {
329337
fixBoolean(this, 'waitForCompletion')
330338
fixBoolean(this, 'dryRun')
339+
fixBoolean(this, 'requireInputFiles')
340+
341+
this.inputGlobs = this.inputGlobs.trim()
331342

332343
if (typeof this.projectId != 'number') {
333344
try {

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)