Skip to content

Commit c4d0f2d

Browse files
authored
Add support for providing a file as inputs-path (#24)
Signed-off-by: tdruez <[email protected]>
1 parent e46d127 commit c4d0f2d

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

.github/workflows/map-deploy-to-develop.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ jobs:
1313

1414
- uses: ./
1515
with:
16-
pipelines: "map_deploy_to_develop"
16+
pipelines: "map_deploy_to_develop:Java"
1717
input-urls:
1818
https://github.com/aboutcode-org/scancode.io/raw/main/scanpipe/tests/data/d2d/jars/from-flume-ng-node-1.9.0.zip#from
1919
https://github.com/aboutcode-org/scancode.io/raw/main/scanpipe/tests/data/d2d/jars/to-flume-ng-node-1.9.0.zip#to
20-
env:
21-
PURLDB_URL: https://public.purldb.io/

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Workflows.
1818
- [Scan repo codebase](#scan-repo-codebase)
1919
- [Run a specific pipeline](#run-a-specific-pipeline)
2020
- [Run multiple pipelines](#run-multiple-pipelines)
21+
- [Specify pipeline options](#specify-pipeline-options)
2122
- [Choose the output formats](#choose-the-output-formats)
2223
- [Provide download URLs inputs](#provide-download-urls-inputs)
2324
- [Fetch pipelines inputs](#fetch-pipelines-inputs)
@@ -123,6 +124,17 @@ steps:
123124
VULNERABLECODE_URL: https://public.vulnerablecode.io/
124125
```
125126
127+
### Specify pipeline options
128+
129+
Use the `pipeline_name:option1,option2` syntax to select optional steps for the
130+
`map_deploy_to_develop` pipeline
131+
132+
```yaml
133+
- uses: aboutcode-org/scancode-action@beta
134+
with:
135+
pipelines: "map_deploy_to_develop:Java,JavaScript"
136+
```
137+
126138
#### Configuring `find_vulnerabilities` Pipeline
127139

128140
The `find_vulnerabilities` pipeline requires access to a VulnerableCode instance,

action.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ inputs:
99
default: "json xlsx spdx cyclonedx"
1010
inputs-path:
1111
description: "Relative path within the $GITHUB_WORKSPACE for pipeline inputs"
12-
default: "${{ github.workspace }}/scancode-inputs"
12+
default: "scancode-inputs"
1313
input-urls:
1414
description: "Provide one or more URLs to download for the pipeline run execution."
1515
required: false
@@ -116,14 +116,30 @@ runs:
116116
echo "PROJECT_WORK_DIRECTORY=$work_directory" >> $GITHUB_ENV
117117
118118
- name: Copy input files to project work directory
119+
if: ${{ !inputs.input-urls }}
119120
shell: bash
120121
run: |
121122
SOURCE_PATH="${{ inputs.inputs-path }}"
123+
[[ "$SOURCE_PATH" != /* ]] && SOURCE_PATH="${{ github.workspace }}/$SOURCE_PATH"
122124
DESTINATION_PATH="${{ env.PROJECT_WORK_DIRECTORY }}/input/"
125+
mkdir -p "$DESTINATION_PATH"
126+
123127
if [ -d "$SOURCE_PATH" ]; then
124-
cp -r "$SOURCE_PATH"/* "$DESTINATION_PATH"
128+
if [ "$(ls -A "$SOURCE_PATH")" ]; then
129+
echo "Copying contents of directory: $SOURCE_PATH → $DESTINATION_PATH"
130+
cp -r "$SOURCE_PATH"/* "$DESTINATION_PATH"
131+
else
132+
echo "Input directory '$SOURCE_PATH' is empty, nothing to copy."
133+
fi
134+
else
135+
echo "Copying file: $SOURCE_PATH → $DESTINATION_PATH"
136+
cp "$SOURCE_PATH" "$DESTINATION_PATH"
125137
fi
126138
139+
echo ""
140+
echo "Input files now in: $DESTINATION_PATH"
141+
ls -lh "$DESTINATION_PATH"
142+
127143
- name: Run the pipelines
128144
shell: bash
129145
run: scanpipe execute --project ${{ inputs.project-name }} --no-color

0 commit comments

Comments
 (0)