Skip to content

Commit bd408fc

Browse files
committed
add scancodeio-extra-packages option for extra packages
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 712cc5c commit bd408fc

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ from your **GitHub Workflows**.
2525
- [Check for compliance issues](#check-for-compliance-issues)
2626
- [Define a custom project name](#define-a-custom-project-name)
2727
- [Use a specific ScanCode.io Docker image](#use-a-specific-scancodeio-docker-image)
28+
- [Install extra Python packages in the image](#install-extra-python-packages-in-the-image)
2829
- [Run source to binary mapping](#run-source-to-binary-mapping)
2930
- [Where does the scan results go?](#where-are-the-scan-results)
3031

@@ -87,6 +88,10 @@ steps:
8788

8889
# ScanCode.io Docker image to use.
8990
scancodeio-image:
91+
92+
# Extra Python packages to install on top of the ScanCode.io image
93+
# (comma-separated, e.g. minecode-pipelines).
94+
scancodeio-extra-packages:
9095
```
9196
9297
## Examples
@@ -230,6 +235,20 @@ against the latest `main` build:
230235
scancodeio-image: "ghcr.io/aboutcode-org/scancode.io:main"
231236
```
232237

238+
### Install extra Python packages in the image
239+
240+
To run pipelines that are not part of the base image, such as `minecode_pipelines`
241+
for PURL mining, provide the packages to install via `scancodeio-extra-packages`.
242+
The action builds a local, throwaway image on top of `scancodeio-image` for this
243+
run only:
244+
245+
```yaml
246+
- uses: aboutcode-org/scancode-action@beta
247+
with:
248+
pipelines: "mine_pypi"
249+
scancodeio-extra-packages: "minecode-pipelines"
250+
```
251+
233252
### Run source to binary mapping
234253

235254
Use this [workflow template](.github/workflows/map-deploy-to-develop-template.yml) for validating the integrity of open-source binary. It compares a project’s binary to its source code. Workflow will generate mapping between compiled binary and its original source code, which helps in spotting any malicious, unexpected, or otherwise undesirable code that may have made its way into the final binary.

action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ inputs:
4040
scancodeio-image:
4141
description: "ScanCode.io Docker image to use."
4242
default: "ghcr.io/aboutcode-org/scancode.io@sha256:6fc8023bc588602ef2ec2b699c2503d8771fe5ef16470475fe64b641f0955f5b" # v37.1.0
43+
scancodeio-extra-packages:
44+
description: "Extra Python packages to install on top of the ScanCode.io image (comma-separated, e.g. minecode-pipelines) (optional)."
45+
required: false
46+
default: ""
4347

4448
runs:
4549
using: "composite"
@@ -51,13 +55,20 @@ runs:
5155
INPUT_PROJECT_NAME: ${{ inputs.project-name }}
5256
INPUT_FAIL_LEVEL: ${{ inputs.compliance-fail-level }}
5357
INPUT_PIPELINES: ${{ inputs.pipelines }}
58+
INPUT_EXTRA_PACKAGES: ${{ inputs.scancodeio-extra-packages }}
5459
run: |
5560
# Docker image ref: registry/name:tag or registry/name@sha256:digest
5661
if [[ ! "$INPUT_IMAGE" =~ ^[a-zA-Z0-9./_:@-]+$ ]]; then
5762
echo "::error::Invalid image name: $INPUT_IMAGE"
5863
exit 1
5964
fi
6065
66+
# Extra packages: pip requirement specifiers, comma-separated
67+
if [[ ! "$INPUT_EXTRA_PACKAGES" =~ ^[]a-zA-Z0-9._,\<\>=!~[\ -]*$ ]]; then
68+
echo "::error::Invalid scancodeio-extra-packages value: $INPUT_EXTRA_PACKAGES"
69+
exit 1
70+
fi
71+
6172
# Project name: alphanumeric, spaces, hyphens, underscores, dots
6273
if [[ ! "$INPUT_PROJECT_NAME" =~ ^[a-zA-Z0-9[:space:]._-]+$ ]]; then
6374
echo "::error::Invalid project name: $INPUT_PROJECT_NAME"
@@ -89,6 +100,19 @@ runs:
89100
# Sanitize project name for artifact usage
90101
echo "SAFE_PROJECT_NAME=${INPUT_PROJECT_NAME//[^a-zA-Z0-9._-]/_}" >> "$GITHUB_ENV"
91102
103+
- name: Build image with extra packages
104+
if: ${{ inputs.scancodeio-extra-packages != '' }}
105+
shell: bash
106+
env:
107+
INPUT_EXTRA_PACKAGES: ${{ inputs.scancodeio-extra-packages }}
108+
run: |
109+
EXTENDED_IMAGE="scancode-action-extended:${GITHUB_RUN_ID}-${GITHUB_JOB}"
110+
docker build -t "$EXTENDED_IMAGE" - <<EOF
111+
FROM $SCANCODEIO_IMAGE
112+
RUN pip install --no-cache-dir ${INPUT_EXTRA_PACKAGES//,/ }
113+
EOF
114+
echo "SCANCODEIO_IMAGE=$EXTENDED_IMAGE" >> "$GITHUB_ENV"
115+
92116
- name: Start and setup the PostgreSQL service
93117
shell: bash
94118
run: |

0 commit comments

Comments
 (0)