Skip to content

Commit c88b2a8

Browse files
committed
move the wrapper script to a proper file
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent d350b62 commit c88b2a8

2 files changed

Lines changed: 22 additions & 25 deletions

File tree

action.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inputs:
3939
default: "false"
4040
scancodeio-image:
4141
description: "ScanCode.io Docker image to use."
42-
default: "ghcr.io/aboutcode-org/scancode.io@sha256:6fc8023bc588602ef2ec2b699c2503d8771fe5ef16470475fe64b641f0955f5b"
42+
default: "ghcr.io/aboutcode-org/scancode.io@v37.1.0"
4343

4444
runs:
4545
using: "composite"
@@ -70,7 +70,7 @@ runs:
7070
exit 1
7171
fi
7272
73-
# Pipeline names: alphanumeric, underscores, commas
73+
# Pipeline names: alphanumeric, underscores, commas, colons
7474
if [[ ! "$INPUT_PIPELINES" =~ ^[a-zA-Z0-9_,:[:space:]]+$ ]]; then
7575
echo "::error::Invalid pipelines value: $INPUT_PIPELINES"
7676
exit 1
@@ -86,12 +86,12 @@ runs:
8686
echo "SCANCODEIO_DB_NAME=scancodeio" >> "$GITHUB_ENV"
8787
echo "SCANCODEIO_DB_USER=scancodeio" >> "$GITHUB_ENV"
8888
echo "SCANCODEIO_DB_PASSWORD=scancodeio" >> "$GITHUB_ENV"
89+
# Workspace location mounted into the container, so outputs are directly accessible
8990
echo "SCANCODEIO_WORKSPACE_LOCATION=/workspace/.scancodeio" >> "$GITHUB_ENV"
9091
echo "SCANCODEIO_IMAGE=$INPUT_IMAGE" >> "$GITHUB_ENV"
92+
# Sanitize project name for artifact usage
9193
SAFE_PROJECT_NAME="${INPUT_PROJECT_NAME//[^a-zA-Z0-9._-]/_}"
9294
echo "SAFE_PROJECT_NAME=$SAFE_PROJECT_NAME" >> "$GITHUB_ENV"
93-
mkdir -p "$GITHUB_WORKSPACE/.scancodeio"
94-
chmod 777 "$GITHUB_WORKSPACE/.scancodeio"
9595
9696
- name: Start and setup the PostgreSQL service
9797
shell: bash
@@ -101,29 +101,10 @@ runs:
101101
sudo -u postgres psql -c "ALTER USER $SCANCODEIO_DB_USER WITH ENCRYPTED PASSWORD '$SCANCODEIO_DB_PASSWORD'"
102102
sudo -u postgres createdb --owner=scancodeio --encoding=UTF-8 "$SCANCODEIO_DB_NAME"
103103
104-
- name: Write scanpipe wrapper script
104+
- name: Install scanpipe wrapper script
105105
shell: bash
106106
run: |
107-
cat > "$RUNNER_TEMP/scanpipe" << 'EOF'
108-
#!/usr/bin/env bash
109-
set -euo pipefail
110-
exec docker run --rm \
111-
--network host \
112-
--read-only \
113-
--tmpfs /tmp \
114-
--tmpfs /opt/scancodeio/.cache:mode=1777 \
115-
--cap-drop ALL \
116-
--security-opt no-new-privileges \
117-
-e SECRET_KEY \
118-
-e SCANCODEIO_DB_NAME \
119-
-e SCANCODEIO_DB_USER \
120-
-e SCANCODEIO_DB_PASSWORD \
121-
-e SCANCODEIO_DB_HOST=localhost \
122-
-e SCANCODEIO_WORKSPACE_LOCATION \
123-
-v "$GITHUB_WORKSPACE:/workspace" \
124-
"$SCANCODEIO_IMAGE" \
125-
scanpipe "$@"
126-
EOF
107+
cp "${{ github.action_path }}/scripts/scanpipe.sh" "$RUNNER_TEMP/scanpipe"
127108
chmod +x "$RUNNER_TEMP/scanpipe"
128109
echo "$RUNNER_TEMP" >> "$GITHUB_PATH"
129110

scripts/scanpipe.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
exec docker run --rm \
4+
--network host \
5+
--user "$(id -u):$(id -g)" \
6+
--cap-drop ALL \
7+
--security-opt no-new-privileges \
8+
-e SECRET_KEY \
9+
-e SCANCODEIO_DB_NAME \
10+
-e SCANCODEIO_DB_USER \
11+
-e SCANCODEIO_DB_PASSWORD \
12+
-e SCANCODEIO_DB_HOST=localhost \
13+
-e SCANCODEIO_WORKSPACE_LOCATION \
14+
-v "$GITHUB_WORKSPACE:/workspace" \
15+
"$SCANCODEIO_IMAGE" \
16+
scanpipe "$@"

0 commit comments

Comments
 (0)